I was thinking that there should be a function that works like chr
but fails in the case when its argument is not a Unicode scalar value.
I usually write my own function this way:
toUnicode :: Int -> Maybe Char
toUnicode x
-- Ranges from "The Unicode Standard".
-- See definition D76 in Section 3.9, Unicode Encoding Forms.
| x >= 0 && x <= 0xD7FF = Just (chr x)
| x >= 0xE000 && x <= 0x10FFFF = Just (chr x)
| otherwise = Nothing
But it would be nice if there's a better way to do that.
is this is something you use to do, you can create an adds modules, like Data.Char.Adds
and import whenever you want. It seems like it doesn't exist in the present. I cannot see another workaround.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With