ImGuiInputTextCallbackData#insertChars works fine when inserting ASCII characters, but inserts wrong characters when trying to add anything else.
Reproduction
When setting the buffer returned by an InputText callback like so:
String newText = "new text";
data.setBufDirty(true);
data.deleteChars(0, data.getBuf().length());
data.insertChars(0, newText);
It works perfectly when using only ASCII characters. However, if you use UTF-8 characters (for example, Cyrillic), the buffer is also fed with some incorrect bytes.
For example, here's how the buffer looks before writing in Russian:
"hello"
And here's how it looks after typing "я":
"helloя�"
If you continue typing, the application will crash entirely with an assertion failure.
Version
1.86.11
What happened?
ImGuiInputTextCallbackData#insertChars works fine when inserting ASCII characters, but inserts wrong characters when trying to add anything else.
Reproduction
When setting the buffer returned by an InputText callback like so:
It works perfectly when using only ASCII characters. However, if you use UTF-8 characters (for example, Cyrillic), the buffer is also fed with some incorrect bytes.
For example, here's how the buffer looks before writing in Russian:
And here's how it looks after typing "я":
If you continue typing, the application will crash entirely with an assertion failure.
Relevant log output