g9ks157k at acme.softbase.org
Sat Dec 25 16:34:13 CET 2010
Am Donnerstag, den 23.12.2010, 10:09 +0000 schrieb Simon Marlow:
> On 16/12/10 20:53, Wolfgang Jeltsch wrote:
> > Hello,
> > on
> > <http://www.haskell.org/ghc/docs/6.12.2/html/libraries/base-22.214.171.124/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 126.96.36.199),
> > 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?
hSetBinaryMode stdout True
hSetEncoding stdout latin1 .
The documentation of hSetBinaryMode says:
This has the same effect as calling hSetEncoding with latin1,
together with hSetNewlineMode with noNewlineTranslation.
It seems that this sentence is wrong.
More information about the Libraries