J2V8 Supports 16bit Characters

When J2V8 was first released, all Java characters passed between Java and V8 were converted to 8bit C-Style strings. For many applications this was just fine, but if your JavaScript contained 16 bit Unicode characters, then you were hosed.

With J2V8 4 this has been fixed. All strings are now referencedย asย uint16_t in C++. Using the JNI API we were able to get the 2 byte string using:

const uint16_t* unicodeString = env->GetStringChars(string, NULL);
and create the V8 String object using String::NewFromTwoByte().

Now you can execute JavaScript, or access JS properties, that contain 16 bit characters such as:

Screen Shot 2016-07-25 at 3.22.19 PM

For more J2V8 Tips and Tricks, follow me on Twitter.