4 ms·
> The only modern language that gets it right is Swift: arguably not true: julia> using Unicode # for some reason HN doesn't allow emoji julia> graphem
by moelf 3y ago
> The only modern language that gets it right is Swift:
arguably not true:
julia> using Unicode
# for some reason HN doesn't allow emoji
julia> graphemes(" ")
length-1 GraphemeIterator{String} for " "
help?> graphemes
search: graphemes
graphemes(s::AbstractString) -> GraphemeIterator
Return an iterator over substrings of s that correspond to the extended graphemes in the string, as defined by Unicode UAX #29. (Roughly, these are what users would perceive as single characters, even though they may contain more than one codepoint; for example a letter combined
with an accent mark is a single grapheme.)
- gwbas1c 3y agoJulia is not a major language like Swift.
- JRaspass 3y agoRaku also gets it right.
- SyrupThinker 3y agoI imagine the author would disagree with that because it does not have the “right” behavior by default. For example indexing and length of the string are done by codeunit. [1] On the other hand Rakus Str type does behave similarly to Swifts: indexing, length and iteration by grapheme; view methods for specific encodings. [2] [1]: https://docs.julialang.org/en/v1/base/strings/ https://docs.julialang.org/en/v1/base/strings/ [2]: https://docs.raku.org/type/Str#routine_chars https://docs.raku.org/type/Str#routine_chars