diff --git a/src/main/java/org/squiddev/cobalt/lib/StringLib.java b/src/main/java/org/squiddev/cobalt/lib/StringLib.java index 882ab94c..ff23b827 100644 --- a/src/main/java/org/squiddev/cobalt/lib/StringLib.java +++ b/src/main/java/org/squiddev/cobalt/lib/StringLib.java @@ -663,7 +663,7 @@ private static int posrelat(int pos, int len) { private static final byte[] CHAR_TABLE; public static boolean isWhitespace(byte b) { - return (CHAR_TABLE[b] & MASK_SPACE) != 0; + return (CHAR_TABLE[b & 0xFF] & MASK_SPACE) != 0; } static { diff --git a/src/test/resources/assert/stringIssues.lua b/src/test/resources/assert/stringIssues.lua index 5200e256..de488c9a 100644 --- a/src/test/resources/assert/stringIssues.lua +++ b/src/test/resources/assert/stringIssues.lua @@ -96,3 +96,6 @@ assert(tostring(1e39) == "1e+39", "Got " .. tostring(1e39)) -- Tiny bits of string concatination local x, y, z = "foo", "bar", "baz" assert(x .. y .. z == table.concat { x, y, z }) + +-- Whitespace on large characters +assert(tonumber(("\128")) == nil)