Cyrillic characters display incorrectly (while retrieving data from Postgresql with psycorg2)

39 views Asked by At

Spend a long time looking for similar problems to no awail.

So, I use Python 3.6 with psycorg2 to retrieve some data from a local database. While connecting, client_encoding='utf8' is specified.

The problem is that, instead of "рика", I get "аЁЄ\xa0". The result doesn't look like a clear example of any encoding, so .encode().decode() with different encodings got me nowhere so far.

What could be helpful:

— column the data is stored in has TEXT datatype (is it a bad choice for storing cyrillic characters?);

— database's Collate and CType is ru_RU.utf8, and "рика" is displayed correctly in psql;

— according to online decoders, "аЁЄ\xa0" is encoded in windows-1251, but it doesn't look like other strings in that encoding I've seen in other answers here.

Any ideas what's wrong there are appreciated.

UPD: TEXT datatype doesn't seem to be a problem; I tried storing 'рика' as a varchar and the return was the exact same mojibake.

0

There are 0 answers