At 2002-08-06 05:38, John Meacham wrote:
One major nit I have with this is the type signature of decodeUTF8 and encodeUTF8 a String should always represent a string of characters, not a byte stream, the signatures should be
decodeUTF8 :: String -> [Word8] encodeUTF8 :: [Word8] -> String
I think you mean encodeUTF8 :: String -> [Word8] decodeUTF8 :: [Word8] -> String ...or even decodeUTF8 :: [Word8] -> Maybe String It might also be useful to have stream functions. Decoding UTF8 octets is a kind of parsing, after all. But yes, you're right. A Char is a Unicode codepoint, nothing else, and certainly not a C 'char'. A C char is _usually_ a Word8 or an Int8, but not necessarily IIRC. I've always thought it a bit odd that the well-specified types Word8, Int8 etc. are hidden away in a package while the machine-dependent Int type, which I avoid in all my code, is in the Prelude. -- Ashley Yakeley, Seattle WA
On Wednesday, 2002-08-07, 01:53, CEST, Ashley Yakeley wrote:
[...] It might also be useful to have stream functions. Decoding UTF8 octets is a kind of parsing, after all.
Exactly. I think, it would not only make sense to encode/decode complete strings but also single characters. So it would be nice to have a parser which reads one character from an UTF-8 stream. And if I want to use such a parser for reading several characters and want to apply another parser to the sequence of characters I've read, I would have an ideal application for the (>>>) arrow operator I talked about in my e-mail from May, 24th. I would just write something like charFromUTF8Parser >>> resultFromStringParser and would have a parser reading UTF-8 and yielding the desired result.
[...]
Wolfgang
participants (2)
-
Ashley Yakeley -
Wolfgang Jeltsch