3.2.3 13 (?, Maven dependency)AdoptOpenJDK jdk-13.0.0.33WindowscoreThe MemoryUtil.memUTF8 methods throw an exception for trailing high surrogates. This could be "intended" given that some (but not all) of the methods calling encodeUTF8 require a valid string:
The specified text is assumed to be a valid UTF-16 string.
However, if this is not intended, maybe the trailing high surrogate could be encoded as regular 3 byte UTF-8 char.
Assumes there is always a low surrogate after a high one.
// Trailing high surrogate char
String str = Character.toString(Character.MIN_HIGH_SURROGATE);
MemoryUtil.memUTF8(str);
Throws StringIndexOutOfBoundsException.
Hey @Marcono1234,
Yes, it is intended. I have added a note to the MemoryUtil class javadoc.
I did some work on it though and it was trivial to make LWJGL compatible with String.getBytes, for all kinds of malformed input. However, when a malformed/unmappable character sequence is detected, there's the question of how to handle it exactly:
String.getBytes does the second, but that may not be what the user wants. So, when dealing with trusted text, use the LWJGL codecs. When not, the JDK's CharsetEncoder/CharsetDecoder can be used instead, configured with the appropriate behavior on invalid input.
@Spasi, thank you for the clarification.
I have sent an e-mail to the Gmail address you have set on GitHub a few weeks ago. Have you had a look at it already? Or is there another way to report issues which should potentially not be public?
Reporting sensitive issues by e-mail is fine. See 272243c, I believe the issues you raised are addressed.