I think that the naming of `len` here is dangerously misleading. Naive ASCII-users will be free to assume that this is counting codepoints rather than bytes. I'd prefer the name `byte_len` in order to make the behavior here explicit.
On Wed, May 28, 2014 at 5:55 AM, Simon Sapin <simon.sa...@exyr.org> wrote: > On 28/05/2014 10:46, Aravinda VK wrote: > >> Thanks. I didn't know about char_len. >> `unicode_str.as_slice().char_len()` is giving number of code points. >> >> Sorry for the confusion, I was referring codepoint as character in my >> mail. char_len gives the correct output for my requirement. I have >> written javascript script to convert from string length to grapheme >> cluster length for Kannada language. >> > > Be careful, JavaScript’s String.length counts UCS-2 code units, not code > points… > > > -- > Simon Sapin > _______________________________________________ > Rust-dev mailing list > Rust-dev@mozilla.org > https://mail.mozilla.org/listinfo/rust-dev >
_______________________________________________ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev