
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
G:\CODE\rlib>ftest3.exe
è
Just '1'
G:\CODE\rlib>chcp 850
Page de codes active : 850
G:\CODE\rlib>ftest3.exe
è
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 change. 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 [1], and, if possible, add a note about Windows console (as it has been done with PostgreSQL documentation). [1] right now I do not remember what the Haskell Report says Regards Manlio