5 ms·
Raku also has a specific string type (Str) that is not just a bag of bytes. Strings are normalized (NFC) when they are created, and multi-codepoint graphemes ar
by elcaro 5y ago
Raku also has a specific string type (Str) that is not just a bag of bytes. Strings are normalized (NFC) when they are created, and multi-codepoint graphemes are represented internally using synthetic codepoints (negative integers), but this is all opaque to the user. This also means that string indexing in Raku is O(1).
Raku passes all the tests. He mentions he didn't find any language that upper-cases "baffle" correctly but Raku does.
Here's my REPL test
> my $n = "noe\x[0308]l"
noël
> $n.chars
4
> $n.flip
lëon
> $n.substr(0, 3)
noë
> my $b = "baffle"
baffle
> $b.substr(2, 1).uniname
LATIN SMALL LIGATURE FFL
> $b.uc
BAFFLE
> "noe\x[0308]l" eq "no\x[00EB]l"
True
HN doesn't handle the cat emojis, so they are not included, but they worked fine.
- b2gills 5y agoTechnically it is MoarVM that handles graphemes as synthetic codepoints. We call it NFG for Normalized Form Grapheme. The JVM and JavaScript backends currently use the built-in string handling features. Which means that they are just as broken as the rest of the code running on them. --- Of further note, you can use ignorecase in regexes to match "baffle". "baffle" ~~ /:ignorecase BAFfLE /;