Skip to content

Commit 46ca6a6

Browse files
committed
Runtime: fix caml_utf8_of_utf16 bug in high surrogate case
1 parent 246df64 commit 46ca6a6

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
* Runtime: fix Int64.of_string overflow check (#1874)
5252
* Runtime: fix caml_string_concat when not using JS strings (#1874)
5353
* Runtime: consistent bigarray hashing across all architectures (#1977)
54+
* Runtime: fix caml_utf8_of_utf16 bug in high surrogate case (#2008)
5455
* Tools: fix jsoo_mktop and jsoo_mkcmis (#1877)
5556
* Toplevel: fix for when use-js-strings is disabled (#1997)
5657

runtime/js/mlBytes.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,14 @@ function caml_utf8_of_utf16(s) {
9797
if (c < 0x800) {
9898
t += String.fromCharCode(0xc0 | (c >> 6));
9999
t += String.fromCharCode(0x80 | (c & 0x3f));
100-
} else if (c < 0xd800 || c >= 0xdfff) {
100+
} else if (c < 0xd800 || c > 0xdfff) {
101101
t += String.fromCharCode(
102102
0xe0 | (c >> 12),
103103
0x80 | ((c >> 6) & 0x3f),
104104
0x80 | (c & 0x3f),
105105
);
106106
} else if (
107-
c >= 0xdbff ||
107+
c > 0xdbff ||
108108
i + 1 === l ||
109109
(d = s.charCodeAt(i + 1)) < 0xdc00 ||
110110
d > 0xdfff

0 commit comments

Comments
 (0)