Quantcast
Channel: Active questions tagged utf-8 - Stack Overflow
Viewing all articles
Browse latest Browse all 1070

Python - Decode UTF-16 file with BOM

$
0
0

I have a UTF-16LE file with BOM. I'd like to flip this file in to UTF-8 without BOM so I can parse it using Python.

The usual code that I use didn't do the trick, it returned unknown characters instead of the actual file contents.

f = open('dbo.chrRaces.Table.sql').read()f = str(f).decode('utf-16le', errors='ignore').encode('utf8')print f

What would be the proper way to decode this file so I can parse through it with f.readlines()?


Viewing all articles
Browse latest Browse all 1070

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>