If you ask someone for an export of data, and you know the data is coming from SQL Server, be sure to clarify what encoding you’d like the export in (if they can configure it) – I spent a bit of time trying to figure out why I couldn’t reliably read a file, and by using a hexeditor, I found the leading bytes were the culprit. Comparing to a listing on Wikipedia, I found the file was in UTF-16, when I’m expecting simple UTF-8 or ASCII. Easy solution though if you’re on a *nix machine:

iconv -f UTF-16 -t UTF-8 input_file > output_file

And you’re done! Easy as pie…when you know what the problem is.

Leave a Reply