我的目标是上传包含名字和姓氏行的文件,解析它并在每个行中为数据库创建Person模型。使用CSV.parse编码问题
我做以下,直到我的文件包含重音(法语单词),它工作正常
file = CSV.parse(the_file_to_parse)
file.each do |row|
person = Person.new(:firstname => row[0], :lastname => row[1])
person.save
end
,我得到
Encoding::UndefinedConversionError: "\xC3" from ASCII-8BIT to UTF-8:
INSERT INTO "people" ("created_at", "firstname", "lastname",
"updated_at") VALUES (?, ?, ?, ?)
什么是处理这个编码问题的最佳方式是什么?
我有ArgumentError:'mode'必须是'r','rb','w'或'wb' – TiSer 2013-01-14 10:37:35