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

utf8.len() never return false when UTF8 has an invalid sequence #13

Open
cvuillemez opened this issue Nov 3, 2017 · 0 comments
Open

utf8.len() never return false when UTF8 has an invalid sequence #13

cvuillemez opened this issue Nov 3, 2017 · 0 comments
Labels
bug

Comments

@cvuillemez
Copy link

@cvuillemez cvuillemez commented Nov 3, 2017

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 ?

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.