On 23 December 2010 05:29, Magicloud Magiclouds <magicloud.magiclo...@gmail.com> wrote: > 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?
I think you are describing the UTF-32 encoding (under the assumption that fromEnum on Char returns the Unicode code point of that character, which I think is true). UTF-32 is capable of describing every Unicode code point so this is indeed non-lossy. UTF-32 is a reasonable wire transfer format (if a bit inefficient!). Don't roll your own encoding logic though, System.IO provides a TextEncoding for UTF-32 you can use to do the job more reliably. Cheers, Max _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe