FasterCSV under Ruby 1.8 will throw an obscure error if the input is given in UTF-16:
FasterCSV::MalformedCSVError: Unquoted fields do not allow \r or \n (line 1).
The solution is to convert the data to UTF-8:
require 'iconv'
csv = Iconv.conv('utf-8', 'utf-16', csv)
Then, :encoding => 'u', flag for FasterCSV should be enough to process this file with no problems.
Advertisement
0 Responses to “FasterCSV and UTF-16”