I
I
Ivan2019-10-02 08:04:37
Python
Ivan, 2019-10-02 08:04:37

How to convert Windows-1251 text file to utf8?

How to convert Windows-1251 encoded text file to utf-8?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2019-10-02
@NeiroNx

For Python3

with open("file.txt","r",encoding="windows-1251") as _in,\ 
     open("new_file.txt","w",encoding="utf-8") as _out:
    _out.write(_in.read())

and for Python2 I'm too lazy to compose

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question