[Haskell-cafe] Grapheme length?
amindfv at mailbox.org
amindfv at mailbox.org
Sat Feb 20 05:59:59 UTC 2021
> > With the "Data.Text.ICU.Char" module, it may be possible to determine
> > grapheme boundaries:
> >
> > https://hackage.haskell.org/package/text-icu-0.7.0.1/docs/Data-Text-ICU-Char.html#g:5
>
> I'll look into this and report back.
>
I'm quite prepared to believe this is wrong/misguided, but I was able to hack something together that works for my uses so far:
import Data.Text.ICU.Char
len = length . filter (==Nothing) . map (property GraphemeClusterBreak) . T.unpack
Example:
len ("🤣h👩🏻elloä❤️❤️👩❤️👩" :: Text)
== 13
Tom
More information about the Haskell-Cafe
mailing list