You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
all demos handle the len parameter of the typedef void(*nk_plugin_copy)(nk_handle, const char*, int len); callback interface as number of bytes in a const char* null terminated C string excluding the nul terminator. But the cut & copy handler code snippet in nk_do_edit() actually passes the count grapheme clusters rendered.
int b = edit->select_start;
int e = edit->select_end;
int begin = NK_MIN(b, e);
int end = NK_MAX(b, e);
text = nk_str_at_const(&edit->string, begin, &unicode, &glyph_len);
if (edit->clip.copy)
edit->clip.copy(edit->clip.userdata, text, end - begin);
In case of muti-byte encodings like utf-8 this leads to corrupted strings.
In case the nk_plugin_copy callback interface presents text as utf-8 encoded to the user, then the len parameter is currently wrongly set inside nk_do_edit(). In case len should represent glyph count, then multi-glyph or accented grapheme clusters are not supported.
In case it is guaranteed by design that nk_plugin_copy passes utf-8 encoded nul terminated string in its const char* anonymous parameter, then it is proposed to set len to number of bytes in the nul terminated string. In that case most of the existing demo backends would probably handle the len parameter correctly as most simply handle len as count bytes.
The text was updated successfully, but these errors were encountered:
Hello,
all demos handle the len parameter of the
typedef void(*nk_plugin_copy)(nk_handle, const char*, int len);
callback interface as number of bytes in a const char* null terminated C string excluding the nul terminator. But the cut & copy handler code snippet innk_do_edit()
actually passes the count grapheme clusters rendered.In case of muti-byte encodings like utf-8 this leads to corrupted strings.
In case the
nk_plugin_copy
callback interface presents text as utf-8 encoded to the user, then the len parameter is currently wrongly set insidenk_do_edit()
. In case len should represent glyph count, then multi-glyph or accented grapheme clusters are not supported.In case it is guaranteed by design that
nk_plugin_copy
passes utf-8 encoded nul terminated string in itsconst char*
anonymous parameter, then it is proposed to set len to number of bytes in the nul terminated string. In that case most of the existing demo backends would probably handle thelen
parameter correctly as most simply handlelen
as count bytes.The text was updated successfully, but these errors were encountered: