
23 Dec
2010
23 Dec
'10
12:29 a.m.
Hi, Recently, I am reading ssh hackage (http://hackage.haskell.org/package/ssh). When at the part of deal with string, I got confused. I am not sure if this is a bug for the hackage, or I am just misunderstanding. An ascii char takes a Word8. So this works (LBS stands for Data.ByteString.Lazy): toLBS :: String -> LBS.ByteString toLBS = LBS.pack . map (fromIntegral . fromEnum) But a UTF-8 char takes a Int (Word32). Then I think the above code would break the data, right? If so, OK, then I think I could make a packInt which turns an Int into 4 Word8 first. Thus under all situation (ascii, UTF-8, or even UTF-32), my program always send 4 bytes through the network. Is that OK? -- 竹密岂妨流水过 山高哪阻野云飞