Closed cvuillemez closed 4 years ago
Hi, I want to use utf8.len() on lua 5.1 to validate a UTF8 sequence but it does not do the job.
When I put a good sequence:
> s = '\207\180' > len, inv = utf8.len(s) > print(len, inv) 1 nil > print(utf8.codepoint(s,1,-1)) 1012
.. function works as expected, it prints the right codepoint and length, but when I put an invalid sequence:
> s = '\255\180' > len, inv = utf8.len(s) > print(len, inv) 2 nil > print(utf8.codepoint(s,1,-1)) 510 180
.. i t does not return the false value and the position of the first invalid byte, like explained here Or maybe this module does not implement utf8 support like LUA 5.3 ?
false
Thanks.
@starwing
Why have you closed this issue? Is it resolved?
Yes, I fixed at HEAD
Hi, I want to use utf8.len() on lua 5.1 to validate a UTF8 sequence but it does not do the job.
When I put a good sequence:
.. function works as expected, it prints the right codepoint and length, but when I put an invalid sequence:
.. i t does not return the
false
value and the position of the first invalid byte, like explained here Or maybe this module does not implement utf8 support like LUA 5.3 ?Thanks.