Search code examples
unicodecharacter-encodingtranslation

Translate unreadable Russian text


I'm trying to read documentation which was written in I believe is Russian, but I'm not sure if what I'm seeing is even encoded correctly. The text looks something like this:

Ãåíåðèðóåò ìàòðèöó ñëó÷àéíûõ ÷èñåë â äèàïàçîíå îò -1 äî 1

(appears as several special A's and o's)

when opened in Firefox. In other programs it looks like this:

���������� ������� ��������� ����� � ��������� �� -1 �� 1

(appears as several question marks)

Is there any hope to translate this?


Solution

  • Decode as CP1251.

    >>> print u'Ãåíåðèðóåò ìàòðèöó ñëó÷àéíûõ ÷èñåë â äèàïàçîí'.encode('latin-1').decode('cp1251')
    Генерирует матрицу случайных чисел в диапазон