python UTF16LE file to UTF8 encoding
Posted
by
Qiao
on Stack Overflow
See other posts from Stack Overflow
or by Qiao
Published on 2011-01-08T10:30:50Z
Indexed on
2011/01/08
10:53 UTC
Read the original article
Hit count: 247
I have big file with utf16le (BOM) encoding.
Is it possible to convert it to usual UTF8 by python?
Something like
file_old = open('old.txt', mode='r', encoding='utf_16_le')
file_new = open('new.txt', mode='w', encoding='utf-8')
text = file_old.read()
file_new.write(text.encode('utf-8'))
http://docs.python.org/release/2.3/lib/node126.html (-- utf_16_le UTF-16LE)
Not working. Can't understand "TypeError: must be str, not bytes" error.
python 3
© Stack Overflow or respective owner