V
V
Vlad2018-08-14 17:02:38
Python
Vlad, 2018-08-14 17:02:38

How to decode UTF-8?

I save letters in a folder. The letters contain the Cyrillic alphabet, and some of them are badly coded as a result. For example, a fragment of a saved letter

<p>\u0414\u043e\u0431\u0440\u044b\u0439 \u0434\u0435\u043d\u044c,</p>

what encoding needs to be decoded in order to correctly save the text in Cyrillic

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
igorzakhar, 2018-08-14
@igorzakhar

>>> s = "<p>\u0414\u043e\u0431\u0440\u044b\u0439 \u0434\u0435\u043d\u044c,</p>"
>>> x = s.encode('utf-8')
>>> x.decode('utf-8')
'<p>Добрый день,</p>'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question