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

String length returns number of bytes instead of number of characters #48

Open
progval opened this issue Jul 25, 2014 · 0 comments
Open

Comments

@progval
Copy link
Contributor

progval commented Jul 25, 2014

LambdaS5's implementation of prim("strlen", str) (which is used in the desugared version of str.length) uses Caml's String.length, which counts the number of bytes of the string.

However, String.length is supposed to count the number of characters.
The two values are the same for pure ASCII strings, but not for other unicode characters.

For instance:

$ echo "'é'.length" > /tmp/test.js
$ ./obj/s5.d.byte -desugar /tmp/test.js -env ./envs/es5.env -apply -eval
2.
$ nodejs
> 'é'.length
1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant