I have been working on eclipse-archived/ceylon-sdk#449, and found that this string: ๐๔ฟฝ๔ฟฝ encodes fine on the JVM but is partially incorrect on JS (too short and distorted near the end). Single characters and longer strings of more common characters work fine.
I've traced this to CharacterBuffer.array, which is an Array<Character> populated from a String by a call to String.copyTo
Printing the String literal and printing CharacterBuffer.array after copyTo:
JVM:
๐๔ฟฝ๔ฟฝ
{ ๐, ๔ฟฝ, ๔ฟฝ }
JS:
๐๔ฟฝ๔ฟฝ
{ ๐, ๔ฟฝ, ๏ฟฝ }
If I swap out string.copyTo(array); for:
for (i->c in string.indexed) {
array.set(i, c);
}
Then JS returns (the same as JVM):
๐๔ฟฝ๔ฟฝ
{ ๐, ๔ฟฝ, ๔ฟฝ }
The native JS implementation looks equivalent to the above Ceylon, but perhaps there's some subtle error?