From cf0d23270e3af24c1cbaebc9c8a1d51eb80b1840 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Sun, 12 Nov 2017 15:34:52 +1100 Subject: src/defs.js: cleanup of to_luastring --- src/defs.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/defs.js b/src/defs.js index 01a48f5..0802376 100644 --- a/src/defs.js +++ b/src/defs.js @@ -186,7 +186,7 @@ const to_jsstring = function(value, from, to) { const to_luastring_cache = {}; const to_luastring = function(str, cache) { - assert(typeof str === "string", "to_luastring expect a js string"); + assert(typeof str === "string", "to_luastring expects a javascript string"); if (cache) { let cached = to_luastring_cache[str]; @@ -196,8 +196,6 @@ const to_luastring = function(str, cache) { let outU8Array = Array(str.length); /* array is at *least* going to be length of string */ let outIdx = 0; for (let i = 0; i < str.length; ++i) { - // 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 <= 0x7F) { outU8Array[outIdx++] = u; @@ -216,10 +214,9 @@ const to_luastring = function(str, cache) { outU8Array[outIdx++] = 0x80 | (u & 63); } } - // Null-terminate the pointer to the buffer. - // outU8Array[outIdx] = 0; if (cache) to_luastring_cache[str] = outU8Array; + return outU8Array; }; -- cgit v1.2.3-70-g09d2