Re: [Haskell-cafe] accents
Thank you Daniel and Ivan, with firefox i finded out that my text file was encoded in WINDOWS-1252. So a commande line such as: iconv -f WINDOWS-1252 -t ISO-8859-1 liste.txt liste2.txt did the trick. Alternatively, i modified my code with: myReadFile a = do h - openFile a ReadMode te - mkTextEncoding CP1252 hSetEncoding h te hGetContents h Corentin On 5/7/10, Daniel Fischer daniel.is.fisc...@web.de wrote: On Friday 07 May 2010 17:05:08 you wrote: I don't know the encoding of my file, how to deduce it? What happens if you open it in a text editor? When it looks right, can you find out from the editor what encoding it used? You could try opening the file in Firefox (or some other browser), go to View - Character Encoding and see what it thinks it is (click Auto-Detect if you have selected some default encoding) if it looks right. If it looks garbled, try selecting different encodings to see if one looks right. You could send me [a part of] the file and I could try and find something out (play a little with iconv). ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] accents
Hello, i'm still struggling with ghci and accents. Prelude é \233 I've installed GHC 6.12.1, which gave me a better result: Prelude putStrLn é é but still: Prelude é \233 I'm trying to search a file with french words with Regex, but i stumble on accents: *Main findRegexFile abnégation [] *Main findRegexFile abn.gation [abn\218gation,abn\218gations] I don't know the encoding of my file, how to deduce it? What is the encoding used by ghci? Unicode? Its seems not be the same since the représentation for é is not the same (\233 and \218). How to have accented characters in ghci? Can't find any ressources on the net. Cheers, Corentin PS: please let me know is you can't see the accented characters in this email, i'll send you another version with pictures. On 3/24/10, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: Dupont Corentin corentin.dup...@gmail.com writes: a - readFile list.txt head $ lines a abn\233gation putStrLn displays a strange character for the é. That is the escaped form of é. You have several options: 1) Use the utf8-string package for I/O 2) Use the text package for I/O (and set an encoding) 3) GHC 6.12.1 uses the system's locale for encoding; as such if your system normally lets you see accented characters then putStrLn, etc. will print them out. -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] accents
On Friday 07 May 2010 17:05:08, Dupont Corentin wrote: Hello, i'm still struggling with ghci and accents. Prelude é \233 That uses the Show instance of Char, which escapes all characters greater than '\127' ('\DEL'), so that's no problem, jut inconvenient. I've installed GHC 6.12.1, which gave me a better result: Prelude putStrLn é é putStrLn doesn't escape printable characters. but still: Prelude é \233 That's interpreted as print é which is putStrLn (show é) , hence escaped. I'm trying to search a file with french words with Regex, but i stumble on accents: *Main findRegexFile abnégation [] *Main findRegexFile abn.gation [abn\218gation,abn\218gations] Okay, your file seems to have a weird encoding. Prelude putStrLn [toEnum 218] Ú I don't know the encoding of my file, how to deduce it? What is the encoding used by ghci? Unicode? I think it uses the system locale and defaults to utf-8 if it can't determine the locale. Its seems not be the same since the représentation for é is not the same (\233 and \218). How to have accented characters in ghci? Can't find any ressources on the net. Cheers, Corentin PS: please let me know is you can't see the accented characters in this email, i'll send you another version with pictures. On 3/24/10, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: Dupont Corentin corentin.dup...@gmail.com writes: a - readFile list.txt head $ lines a abn\233gation putStrLn displays a strange character for the é. That is the escaped form of é. You have several options: 1) Use the utf8-string package for I/O 2) Use the text package for I/O (and set an encoding) 3) GHC 6.12.1 uses the system's locale for encoding; as such if your system normally lets you see accented characters then putStrLn, etc. will print them out. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] accents
Hello, i have a list of french words with accents. How could i handle them? If i load them with ghci i get: a - readFile list.txt head $ lines a abn\233gation putStrLn displays a strange character for the é. Cheers, Corentin ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] accents
Dupont Corentin corentin.dup...@gmail.com writes: a - readFile list.txt head $ lines a abn\233gation putStrLn displays a strange character for the é. That is the escaped form of é. You have several options: 1) Use the utf8-string package for I/O 2) Use the text package for I/O (and set an encoding) 3) GHC 6.12.1 uses the system's locale for encoding; as such if your system normally lets you see accented characters then putStrLn, etc. will print them out. -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] accents
-Ursprüngliche Nachricht- Von: Dupont Corentin corentin.dup...@gmail.com Gesendet: 24.03.2010 11:01:32 An: haskell haskell-cafe@haskell.org Betreff: [Haskell-cafe] accents Hello, i have a list of french words with accents. How could i handle them? If i load them with ghci i get: a - readFile list.txt head $ lines a abn\233gation putStrLn displays a strange character for the é. Cheers, Corentin Encoding problem. Either you want System.IO.UTF8.putStrLn (perhaps also readFile), or your file is encoded in latin1 or something and ghci tries to output it as UTF8-encoded. The secure way would be to iconv the file to utf-8 and use the System.IO.UTF8 I/O-functions. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe