LiquidPlayer / LiquidCore

Node.js virtual machine for Android and iOS
MIT License
1.01k stars 127 forks source link

Character encoding problem #117

Closed garronej closed 4 years ago

garronej commented 5 years ago

Hi, JNI 's NewStringUTF throw when passed non 'modified UTF-8' valid string. This make it impossible to work with emoji and non latin languages.

The issue is described in detail here: sqlcipher/android-database-sqlcipher/issues/199

Log:

org.linphone.core.LinphoneCoreException: Cannot interpret [sip:+336718370395#6@dev.semasim.com] ( NOT UI THREAD ) 06-28 18:13:19.729 32388-32388/com.semasim.android A/art: sart/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION: input is not valid Modified UTF-8: illegal start byte 0xf0 sart/runtime/check_jni.cc:65] string: '{"type":"MESSAGE","pduDateTime":1561723397000,"text":"😙😙😙😙🤷‍♂️😊🙂🤷‍♂️🧚‍♂️🧚‍♂️😊😙😙😙😙🤷‍♂️😊🙂🤷‍♂️🧚‍♂️🧚‍♂️😊❤️🤗🤷‍♂️😞😊🤷‍♂️❤️😙😙😙😙🤷‍♂️😊🙂🤷‍♂️🧚‍♂️🧚‍♂️😊❤️🤗🤷‍♂️😞😙😙😙😙🤷‍♂️😊🙂😙😙😙😙🤷‍♂️😊🙂🤷‍♂️🧚‍♂️😙😙😙😙🤷‍♂️😊🙂🤷‍♂️🧚‍♂️🧚‍♂️😊❤️🤗🤷‍♂️😞😊🤷‍♂️🧚‍♂️😊❤️🤗🤷‍♂️😞😊🤷‍♂️🤷‍♂️🧚‍♂️🧚‍♂️😊❤️🤗🤷‍♂️😞😊🤷‍♂️😊🤷‍♂️🤗🤷‍♂️😞😊🤷‍♂️"}' sart/runtime/check_jni.cc:65] in call to NewStringUTF sart/runtime/check_jni.cc:65] from java.lang.String org.liquidplayer.javascript.JNIJSValue.toStringCopy(long)

The workaround seems to be to convert UTF-8 from the input to UTF-16 and call NewString instead of NewStringUTF. I would have done it myself but I got discouraged by the complicated build process...

Anyway thanks for making available this great tool.

Regards

ericwlange commented 5 years ago

Thanks for reporting. This sounds like a simple fix.

ericwlange commented 4 years ago

This has been fixed in 0.7.x