Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

In Julia, iterating over a string by default behaves like `each_char`.

`codeunits(str)` lets you access the underlying code units, which is bytes for the default UTF-8 encoding. (External packages implement UTF-16 and others, and there `codeunits` could return non-bytes, for eg. 16-bit values for UTF-16.)

The Unicode stdlib provides `graphemes(str)`, the equivalent of `each_grapheme_cluster`.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: