System.IO.latin1 docs

Simon Marlow marlowsd at gmail.com
Thu Dec 23 11:09:48 CET 2010


On 16/12/10 20:53, Wolfgang Jeltsch wrote:
> Hello,
>
> on
>
> <http://www.haskell.org/ghc/docs/6.12.2/html/libraries/base-4.2.0.1/System-IO.html#v%3Alatin1>
>
> it says:
>
>> An attempt to write a character greater than '\255' to a Handle using
>> the latin1 encoding will result in an error.
>
> However, according to my experience (with GHC 6.12.1 and base 4.2.0.0),
> latin1 just outputs a character '\cccc' as cccc `mod` 256.

It seems to be working as advertised for me:

$ ghc-6.12.1 --interactive
GHCi, version 6.12.1: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package ffi-1.0 ... linking ... done.
Prelude> import System.IO
Prelude System.IO>  hSetEncoding stdout latin1
Prelude System.IO>  putChar '\256'
*** Exception: <stdout>: hPutChar: invalid argument (character is out of 
range for this encoding)
Prelude System.IO>

I get the same results with 7.0.1.  Can you tell me how to reproduce the 
problem you're seeing?

Cheers,
	Simon



More information about the Libraries mailing list