Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write Russian characters in file?

In console when I'm trying output Russian characters It gives me ???????????????

Who know why?

I tried write to file - in this case the same situation.

for example

f=open('tets.txt','w')
f.write('some russian text')
f.close

inside file is - ?????????????????????????/

or

p="some russian text"
print p
?????????????

In additional Notepad don't allow me to save file with Russian letters. I give this:

This file contains characters in Unicode format which will be lost if you save this file as an ANSI encoded text file. To keep the Unicode information, click Cancel below and then select one of the Unicode options from the Encoding drop down list. Continue?

How to adjust my system, so I will don't have this problems.

like image 992
Pol Avatar asked Jul 07 '10 20:07

Pol


People also ask

How do you type Russian characters?

On the “Keyboards and Languages” tab, click on “Change Keyboards” > “Add” > “Russian.” 4. Expand the option of “Russian” and then expand the option “Keyboard.” Select the keyboard layout marked as “Russian.” You can ignore other keyboard layouts. Click “OK” and then “Apply.”

How can I read Russian in notepad?

Open your Notepad program. FROM the Notepad MENU, select the TXT-file that you have just saved with MS-Word. Just beside the "open" button, you have the possibility to choose the encoding format; select UTF-8. You should be able to read the Russian text as you saw it with MS-Word.

What encoding to use for Russian?

Russian and other Slavic languages are written in Cyrillic script, which is most often represented by the use of the KOI8-R or the ISO 8859-5 character sets.


1 Answers

Try opening the file using codecs, you need to

import codecs

and then

writefile = codecs.open('write.txt', 'w', 'utf-8')
like image 186
Hagge Avatar answered Sep 18 '22 13:09

Hagge