aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-11-12 15:34:52 +1100
committerdaurnimator <quae@daurnimator.com>2017-11-12 15:34:52 +1100
commitcf0d23270e3af24c1cbaebc9c8a1d51eb80b1840 (patch)
treeac7ac13f9d8ed8cbbd1cf7c7e82d1e4c685f8fdb /src
parent902d145793959ce0347b202303f8cb34223e6b04 (diff)
downloadfengari-cf0d23270e3af24c1cbaebc9c8a1d51eb80b1840.tar.gz
fengari-cf0d23270e3af24c1cbaebc9c8a1d51eb80b1840.tar.bz2
fengari-cf0d23270e3af24c1cbaebc9c8a1d51eb80b1840.zip
src/defs.js: cleanup of to_luastring
Diffstat (limited to 'src')
-rw-r--r--src/defs.js7
1 files changed, 2 insertions, 5 deletions
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;
};