aboutsummaryrefslogtreecommitdiff
path: root/src/lstrlib.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/lstrlib.js')
-rw-r--r--src/lstrlib.js7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/lstrlib.js b/src/lstrlib.js
index 1b62db1..4bd8664 100644
--- a/src/lstrlib.js
+++ b/src/lstrlib.js
@@ -53,13 +53,14 @@ const str_len = function(L) {
const str_char = function(L) {
let n = lapi.lua_gettop(L); /* number of arguments */
- let p = "";
+ let p = [];
for (let i = 1; i <= n; i++) {
let c = lauxlib.luaL_checkinteger(L, i);
lauxlib.luaL_argcheck(L, c >= 0 && c <= 255, "value out of range"); // Strings are 8-bit clean
- p += String.fromCharCode(c);
+ p.push(c);
}
- lapi.lua_pushstring(L, p);
+ lapi.lua_pushstring(L, "");
+ L.stack[L.top - 1].value = p; // Since value are already capped, avoid conversion
return 1;
};