mirror of
https://github.com/ccxvii/mujs.git
synced 2026-02-06 01:41:37 +08:00
Support 4-byte UTF-8 sequences.
The following functions are no longer restricted to 16-bit integer values: String.fromCharCode() String.prototype.charCodeAt() repr() will not escape SMP characters, as doing so would require conversion to surrogate pairs, but will encode these characters as UTF-8. Unicode characters in the BMP will still be escaped with \uXXXX as before. JSON.stringify() only escapes control characters, so will represent all non-ASCII characters as UTF-8. We do no automatic conversions to/from surrogate pairs. Code that worked with surrogate pairs should not be affected by these changes.
This commit is contained in:
@@ -310,7 +310,7 @@ static void S_fromCharCode(js_State *J)
|
||||
}
|
||||
|
||||
for (i = 1; i < top; ++i) {
|
||||
c = js_touint16(J, i);
|
||||
c = js_touint32(J, i);
|
||||
p += runetochar(p, &c);
|
||||
}
|
||||
*p = 0;
|
||||
|
||||
Reference in New Issue
Block a user