From 7ac9666b8d9c840dfed8105768becaf5e228f84a Mon Sep 17 00:00:00 2001 From: daurnimator Date: Mon, 29 Jan 2018 23:28:38 +1100 Subject: src/lstrlib.js: Add binary safe string.lower and string.upper --- src/lstrlib.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'src/lstrlib.js') diff --git a/src/lstrlib.js b/src/lstrlib.js index b2c2818..fcaea79 100644 --- a/src/lstrlib.js +++ b/src/lstrlib.js @@ -673,15 +673,29 @@ const str_reverse = function(L) { const str_lower = function(L) { let s = luaL_checkstring(L, 1); - // TODO: will fail on invalid UTF-8 - lua_pushstring(L, to_luastring(to_jsstring(s).toLowerCase())); + let l = s.length; + let r = new Uint8Array(l); + for (let i=0; i