xml - Python: How do I read and parse a unicode utf-8 text file? -


I am exporting UTF-8 text from ext2 and I want to parse the incoming data for reading and parsing I am I have read all the online information, for example:

  txtFile = codecs.open ('halout.txt', 'r', 'utf-8')) for line in TxtFile: Print repr (line)  

The error I am getting is:

Unicodecode Error: 'utf8' can not decode byte 0xff in codec condition 0: unexpected Code Byte

Seeing text file in hex editor, the first value is also tried by FFFE:

  txtFile.seek (2)  

right after the 'open', but this is just a different error Causes.

edit this one

, from coments, it is a utf-16 bom

  codecs.open ('foo.txt', 'r 


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -