[Haskell-cafe] Has character changed in GHC 6.8?
Duncan Coutts
duncan.coutts at worc.ox.ac.uk
Tue Jan 22 05:46:52 EST 2008
On Tue, 2008-01-22 at 12:56 +0300, Miguel Mitrofanov wrote:
> > > chr . ord $ 'å'
> > '\229'
> > What would I have to do to get an 'å' from '229'?
>
> It seems you already have it; 'å' is the same as '\229'.
Yes.
> But IO output is still 8-bit, so when you ask ghci to print 'å', you get '\229'.
No. :-)
if you 'print' it you get:
print 'å'
= putStrLn (show 'å')
= putStrLn "\229"
this has nothing to do with 8-bit IO. It's just what 'show' does for
Char.
If you..
putStrLn "å"
then you do get the low 8 bits being printed. But that's not what is
going on above.
> You can use utf-string library (from hackage).
import qualified Codec.Binary.UTF8.String as UTF8
putStrLn (UTF8.encodeString "å")
or just:
import qualified System.IO.UTF8
UTF8.putStrLn "å"
Duncan
More information about the Haskell-Cafe
mailing list