-
Notifications
You must be signed in to change notification settings - Fork 929
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
gsub has trouble with \0 #759
Comments
LuaJIT is compatible to Lua 5.1 which has the same problem, \0 can be used in patterns since Lua 5.2. Use |
thank you! |
That doesn't seem to be the case. Lua 5.1.5 behaves the same as Lua 5.3 for the first two cases.
For the 3rd case, Lua 5.3 printed a special character after 'o' which should be the "\1".
The "%z" does seem work with LuaJIT. By replacing the "\0" in the patterns with "%z", LuaJIT behaves the same as Lua 5.3 |
You need to inspect the bytes of the returned string to see what's actually happening. Your console doesn't show some of these characters. The pattern string is terminated at the first Oh, and But all of this is moot, since the Lua 5.1 manual clearly says |
You can see actual content using this function function showbytes(str)
local comma = false
for i = 1, #str do
io.write(comma and ", " or "", str:sub(i, i), " (", str:byte(i, i), ")")
comma = true
end
io.write("\n")
io.flush()
end |
This is probably an issue with string termination in C but it works fine in lua
The text was updated successfully, but these errors were encountered: