I am trying to access some Russian TeX files, but when I open it in TeXstudio (or any other editor), the text is not readable. For example, this is a line from one file:

Ќ ©¤гвбп «Ё в ЄЁҐ а §«Ёз­лҐ ўҐйҐб⢥­­лҐ зЁб«  $a$, $b$, $c$, зв® Їап¬лҐ $y=ax+b$, $y=bx+c$, $y=cx+a$ ЇҐаҐбҐЄ овбп ў ®¤­®© в®зЄҐ?

In earlier topics in Stack Exchange, it has been advised to set the editor's font encoding from UTF-8 to windows-1251, but this doesn't seem to work in TeXstudio.

  • 8
    well if your original file is 1251-encoded then the best would be to convert it to utf8 first. (If you experiment with reencoding, store a backup in a safe place, one can easily do it wrong). Commented Apr 11, 2023 at 12:33
  • hard to be sure from an image but I would guess the file is UTF-8 and your editor is using cp1251 or similar. First question though is does the latex work (even if it shows as nonsense in the editor) if it works, the file is fine, and you just need to fix the editor settings, if it does not work, the file has been corrupted. Commented Apr 11, 2023 at 13:11
  • Install several editors for experimenting.
    – user206750
    Commented Apr 11, 2023 at 13:55
  • 4
    UTF-8 and windows-1251 are not font encodings but are character encodings. You need to know what character encoding your TeX files are encoded in, i.e., what byte-sequences denote what characters. You need to provide this information to your TeX-input-editor in order to have it display the TeX files properly. Commented Apr 11, 2023 at 16:16
  • 1
    If I understand the question correctly, instead of the tag "font-encodings" the tag "input-encodings" should be used. Commented Apr 11, 2023 at 16:31

3 Answers 3


The text seems to be encoded as CP866. According to Wikipedia on this encoding:

Code page 866 (CCSID 866) (CP 866, "DOS Cyrillic Russian") is a code page used under DOS and OS/2 in Russia to write Cyrillic script.

You can re-encode it in for example Python:

mytext = "Ќ ©¤гвбп «Ё в ЄЁҐ а §«Ёз­лҐ ўҐйҐб⢥­­лҐ зЁб«  $a$, $b$, $c$, зв® Їап¬лҐ $y=ax+b$, $y=bx+c$, $y=cx+a$ ЇҐаҐбҐЄ овбп ў ®¤­®© в®зЄҐ?"

The code first interprets the utf-8 sequence as single bytes (with cp1251, the 'standard' cyrillic encoding) and then maps those bytes into cp866.

This prints (newline added for readability):

Н йдутся ли т кие р зличные вещественные числ  $a$, $b$, $c$, 
что прямые $y=ax+b$, $y=bx+c$, $y=cx+a$ пересек ются в одной точке?

which translates as:

Are there different real numbers $a$, $b$, $c$
such that the lines $y=ax+b$, $y=bx+c$, $y=cx+a$ intersect in one point?
  • For someone like me, the math might as well be cp866 Russian. But I wonder why someone using TeX for math in Russian would be using DOS.
    – user287367
    Commented Apr 11, 2023 at 16:17
  • @rallg probably this is an old file that the asker found somewhere in an archive, in the 1980s and 1990s this codepage (and DOS itself) were widely used in Russia according to the Wikipedia page.
    – Marijn
    Commented Apr 11, 2023 at 17:02
  • 6
    @rallg 1980 doesn't seem so long ago Commented Apr 11, 2023 at 19:15
  • 1
    @Photon That is interesting indeed, and difficult to correct automatically afterwards unfortunately. However, with a bit of luck this is an unprintable character in the original source when displayed in the wrong encoding (which the OP used to copy into the question), and when you re-encode the original file you might get the а's back.
    – Marijn
    Commented Apr 11, 2023 at 20:53
  • 3
    It may be better if the script loads the tex file directly rather than like mytext = "<what you see in OP's post>" (the string representation in OP's post was lossy)
    – qrsngky
    Commented Apr 12, 2023 at 4:20

Well, I used https://2cyr.com/decode/ to figure out what happened.

In bash you can save your text as utf-8 file "t.txt" and call iconv

iconv -f utf-8 -t cp1251 t.txt | iconv -f cp866 -t utf-8

It produces

Найдутся ли такие различные вещественные числ  $a$, $b$, $c$, что прямые $y=ax+b$, $y=bx+c$, $y=cx+a$ пересекаются в одной точке?

числ should be числа, but other stuff looks good for me.

  • I think the OP has the original files, and not just the quoted text above. So he can do it like iconv -f cp866 -t utf-8 original.tex > unicode_version.tex
    – qrsngky
    Commented Apr 12, 2023 at 4:26
  • Seems legit, but for sure I do not know what OP possesses and which encoding his system uses. Could he maybe share files ?
    – kerzol
    Commented Apr 12, 2023 at 7:28

A few characters may have become invalid (when trying to load it in the wrong encoding) and be removed by the system (or irreversibly replaced with another character) before you even pasted the code here.

The original was apparently saved in CP866, and the unreadable code you posted was the result of an attempt to load it as Windows-1251.
I found that every Cyrillic "а" (saved as CP866 but loaded as Windows-1251) becomes a no-break space character (ASCII: 0xa0), which is then further replaced by a regular space when it is posted to some sites.

If you have the original file, you can try opening the file in Notepad++ and choose Encoding > Character sets > Cyrillic > OEM 866, then you can copy/paste elsewhere with the proper encoding.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .