/ Published in: Python
Read a windows UTF-16 file (such as a BCP dump from SQL Server) that contains ASCII characters and occasional nulls
Expand |
Embed | Plain Text
import codecs with codecs.open(filename, 'rb', encoding='utf-16') as stream: for line in stream: yield codecs.encode(line.replace('\0',''), 'ascii', 'replace')
You need to login to post a comment.
