[Haskell-cafe] Same compiled program behaving differently when
called from ghci and shell
manlio_perillo at libero.it
Sun Nov 21 15:52:15 EST 2010
Il 21/11/2010 19:28, Bruno Damour ha scritto:
> Of course you're right but that was a surprise to me...
> G:\CODE\rlib>chcp 1252
> Page de codes active: 1252
> Just '1'
> G:\CODE\rlib>chcp 850
> Page de codes active : 850
> Just '2'
> Quite treacherous IMHO ? Or what
It is not treacherous at all.
When you open a file, GHC use localeEncoding, that, as the name suggest,
depends on system current codepage (in Windows case).
In your example, you are simply changing the codepage, and thus the
program behaviour changes accordling.
It is the same as when you have a program that print some environ
parameter (as an example with System.Environment.getEnvironment).
Of course if you change the OS environ from the console, that program
behaviour will change.
And it is also the same when your program read a file content.
If you change the file content from elsewere, the program behaviour will
As for the original example, I just think that the GHC user guide
*should* clearly explain what does it means to open a file in text mode
, and, if possible, add a note about Windows console (as it has been
done with PostgreSQL documentation).
 right now I do not remember what the Haskell Report says
More information about the Haskell-Cafe