Answer the question
In order to leave comments, you need to log in
How to convert Cyrillic to ASCII?
I am using Python3.
There is a line strTxt = 'ной'
I'm trying to convert it to ascii. Something doesn't work.
x = 'ной'.encode(encoding='ascii')
UnicodeEncodeError: 'ascii' codec cant encode characters in position 0-2: ordinal not in range(128)
x = b'ной'
SyntaxError: bytes can only contain ASCII literal characters.
for char in 'ной':
x=b''
r = (ord(char) & 0xff)
x += r.to_bytes(1,byteorder='big')
print(x)
b'9'
b'\xed\xee\xe9'
Answer the question
In order to leave comments, you need to log in
Your cryptic encoding is called cp1251 .
But keep in mind that this relic of the past does not conform to the unicode standard. On modern operating systems, there may be problems with this encoding. For modern portable solutions it's better to use utf8 as pygame said .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question