Strings containing escapes get incorrectly un-escaped when converted to Lua · Issue #1551 · TypeScriptToLua/TypeScriptToLua · GitHub
Skip to content

Strings containing escapes get incorrectly un-escaped when converted to Lua #1551

Open

Description

@CircuitButKerbin

Issue

Strings containing escaped characters get incorrectly un-escaped when converted into lua

Reproduction

Link to the program on the TSTL Playground
The program is:

let someString = "\x80\x00\x20\x7A\x3F\x3E"
print(someString.length)
let str: string = "";
for (let i = 0; i < someString.length; i++) {
    str += string.format("\\x%02X", string.byte(someString[i]));
}
print(str);

Which should print 6 (length of the string) then \x80\x00\x20\x7A\x3F\x3E (the escaped form of the string), but instead prints 7 \xC2\x80\x00\x20\x7A\x3F\x3E, because the string is being un-escaped incorrectly and is adding a non-breaking space to the beginning of the string.
This can be also be seen with the line let someString = "\x80\x00\x20\x7A\x3F\x3E" being converted to someString = "�\0 z?>"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions