You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Если Вы не являетесь адресатом такой информации, просим незамедлительно уведомить об этом отправителя, уничтожить настоящее Сообщение и воздержаться от раскрытия, передачи или копирования такой информации каким-либо третьим лицам, а также иного использования настоящего Сообщения. Электронные сообщения не являются безопасными или свободными от ошибок, могут содержать вирусы и доставляться с задержкой, и отправитель не несет ответственности за такие случаи. Отправитель оставляет за собой право отслеживать, регистрировать и сохранять электронные сообщения. Вступая с нами в переписку, Вы считаетесь проинформированными обо всем, что указано выше.
While working on #234 I looked into this one and I think the encoding is misidentified: it's KOI8-R rather than CP437 or CP866.
In KOI8-R, 0xD0 is п and 0xD1 is я — the two lead bytes that Cyrillic uses in UTF-8 — and 0x95 and 0x81 are ∙ and │. That is why the text comes out as Cyrillic letters interleaved with box-drawing characters instead of the usual Ð/Ñ pattern.
Until there's a release, you can recover the text with one line:
>>>"п∙я│п╩п╦ п▓я▀ п╫п╣ я▐п╡п╩я▐п╣я┌п╣я│я▄".encode("koi8-r").decode("utf-8")
'Если Вы не являетесь'
I tried cp866, koi8-u, iso-8859-5 and mac-cyrillic on your sample as well; none of them can even encode it, so KOI8-R is the only one that round-trips.
Worth knowing that the round-trip alone isn't enough inside ftfy: is_bad() also has to flag the text, and no current alternative pairs a Cyrillic letter with a box-drawing character. #234 has both halves.
Activity
sebollin commentedon Aug 8, 2026
While working on #234 I looked into this one and I think the encoding is misidentified: it's KOI8-R rather than CP437 or CP866.
In KOI8-R,
0xD0isпand0xD1isя— the two lead bytes that Cyrillic uses in UTF-8 — and0x95and0x81are∙and│. That is why the text comes out as Cyrillic letters interleaved with box-drawing characters instead of the usualÐ/Ñpattern.Until there's a release, you can recover the text with one line:
I tried
cp866,koi8-u,iso-8859-5andmac-cyrillicon your sample as well; none of them can even encode it, so KOI8-R is the only one that round-trips.Worth knowing that the round-trip alone isn't enough inside ftfy:
is_bad()also has to flag the text, and no current alternative pairs a Cyrillic letter with a box-drawing character. #234 has both halves.