Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haskell IO russian symbols

I an trying to process a file which contains russian symbols. When reading and after writing some text to the file I get something like:

\160\192\231\229\240\225\224\233\228\230\224\237

How can I get normal symbols?

like image 812
Anton Avatar asked May 15 '10 12:05

Anton


2 Answers

If you are getting strings with backslashes and numbers in, then it sounds like you might be calling "print" when you want to call "putStr".

like image 194
psmears Avatar answered Oct 16 '22 15:10

psmears


If you deal with Unicode, you might try utf8-string package

import System.IO hiding (hPutStr, hPutStrLn, hGetLine, hGetContents, putStrLn)
import System.IO.UTF8
import Codec.Binary.UTF8.String (utf8Encode)
main = System.IO.UTF8.putStrLn "Вася Пупкин"

However it didn't work well in my windows CLI garbling the output because of codepage. I expect it to work fine on other Unix-like systems if your locale is set correctly. However writing to file should be successfull on all systems.

UPDATE:

An example on encoding package usage.

like image 26
YasirA Avatar answered Oct 16 '22 14:10

YasirA