Posted By

Twain on 06/09/09


python unicode sqlserver bcp

Versions (?)

Read UTF-16 with NULL's, as received from the SQL Server "bcp" utility

 / Published in: Python

Read a windows UTF-16 file (such as a BCP dump from SQL Server) that contains ASCII characters and occasional nulls

  1. import codecs
  2. with, 'rb', encoding='utf-16') as stream:
  3. for line in stream:
  4. yield codecs.encode(line.replace('\0',''), 'ascii', 'replace')

Report this snippet  

You need to login to post a comment.