Description
Unicode utilities for Haskell.
Description
Zenacy Unicode includes tools for checking byte order marks (BOM) and cleaning data to remove invalid bytes. These tools can help ensure that data pulled from the web can be parsed and converted to text.
README.md
Zenacy Unicode
Zenacy Unicode includes tools for checking byte order marks (BOM) and cleaning data to remove invalid bytes. These tools can help ensure that data pulled from the web can be parsed and converted to text.
The following is an example of converting dubious data to a text.
textDecode :: ByteString -> Text
textDecode b =
case bomStrip b of
(Nothing, s) -> T.decodeUtf8 $ unicodeCleanUTF8 s -- Assume UTF8
(Just BOM_UTF8, s) -> T.decodeUtf8 $ unicodeCleanUTF8 s
(Just BOM_UTF16_BE, s) -> T.decodeUtf16BE s
(Just BOM_UTF16_LE, s) -> T.decodeUtf16LE s
(Just BOM_UTF32_BE, s) -> T.decodeUtf32BE s
(Just BOM_UTF32_LE, s) -> T.decodeUtf32LE s