aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJukka Jylänki <jujjyl@gmail.com>2013-09-01 18:52:21 +0300
committerAlon Zakai <alonzakai@gmail.com>2013-09-10 14:39:32 -0700
commit0869e83dee252df71177f7b0b7e0e8b2ab3de321 (patch)
treede68b2e89a9c95a3fdf1a862e3d33e9f7660704e
parentad8acfe6add300ff7968d4f12affaefc1b29f887 (diff)
Fix UTF-16 surrogate detection.
-rw-r--r--src/preamble.js2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/preamble.js b/src/preamble.js
index 3cf74b9d..5f0d720e 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -599,7 +599,7 @@ function stringToUTF32(str, outPtr) {
for(var iCodeUnit = 0; iCodeUnit < str.length; ++iCodeUnit) {
// Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! We must decode the string to UTF-32 to the heap.
var codeUnit = str.charCodeAt(iCodeUnit); // possibly a lead surrogate
- if (codeUnit >= 0xD800) {
+ if (codeUnit >= 0xD800 && codeUnit <= 0xDFFF) {
var trailSurrogate = str.charCodeAt(++iCodeUnit);
codeUnit = 0x10000 + ((codeUnit & 0x3FF) << 10) | (trailSurrogate & 0x3FF);
}