possible problem with JNI GetStringUTFChars
Alan Snyder
javalists at cbfiddle.com
Thu Jan 24 18:39:49 UTC 2019
Thank you. That post does explain what is happening, but leaves open the question of whether GetStringUTFChars should be changed.
What is the value of the current implementation of GetStringUTFChars versus one that returns true UTF-8?
Alan
> On Jan 24, 2019, at 10:32 AM, Claes Redestad <claes.redestad at oracle.com> wrote:
>
> Hi Alan,
>
> GetStringUTFChars unfortunately doesn't give you true UTF-8, but a modified UTF-8 sequence
> as used by the VM internally for historical reasons.
>
> See answers to this related question on SO (which contains links to official docs):
> https://stackoverflow.com/questions/32205446/getting-true-utf-8-characters-in-java-jni
>
> HTH
>
> /Claes
>
> On 2019-01-24 19:23, Alan Snyder wrote:
>> I am having a problem with file names that contain emojis when passed to a macOS system call.
>>
>> Things work when I convert the path to bytes in Java, but fail (file not found) when I convert the path to bytes in native code using GetStringUTFChars.
>>
>> For example, where String.getBytes() returns
>>
>> -16 -97 -115 -69
>>
>> GetStringUTFChars returns:
>>
>> -19 -96 -68 -19 -67 -69
>>
>> I’m not a UTF expert, so can someone say whether I should file a bug report?
>>
>> (Tested in JDK 9, 11, and a fairly recent 12)
>>
>
More information about the core-libs-dev
mailing list