Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
CircuitButKerbin opened this issue Mar 27, 2024 · 0 comments
Labels
bug scope: transformation Transformation of TS to Lua

Comments

@CircuitButKerbin
Copy link

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?>"

@Perryvw Perryvw added bug scope: transformation Transformation of TS to Lua labels Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug scope: transformation Transformation of TS to Lua
Projects
None yet
Development

No branches or pull requests

2 participants