From ed7815d9a5da88e7c83a0596fb75249c3ce165ab Mon Sep 17 00:00:00 2001 From: daurnimator Date: Sun, 12 Nov 2017 14:29:42 +1100 Subject: src/defs.js: Fix conversion of non-BMP unicode codepoints Adds tests for to_luastring --- src/defs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/defs.js b/src/defs.js index 4d5de3b..f76471a 100644 --- a/src/defs.js +++ b/src/defs.js @@ -193,7 +193,7 @@ const to_luastring = function(str, cache) { // See http://unicode.org/faq/utf_bom.html#utf16-3 // For UTF8 byte structure, see http://en.wikipedia.org/wiki/UTF-8#Description and https://www.ietf.org/rfc/rfc2279.txt and https://tools.ietf.org/html/rfc3629 let u = str.codePointAt(i); - if (u >= 0xD800) i++; // If it was a surrogate pair it used up two bytes + if (u >= 0x10000) i++; // It was a surrogate pair and hence used up two bytes if (u <= 0x7F) { outU8Array[outIdx++] = u; } else if (u <= 0x7FF) { -- cgit v1.2.3-70-g09d2