Encoding error while writing data from excelfile to database (mysql)

徘徊边缘 提交于 2019-12-22 19:47:04

问题


I get this error when writing to database:

Encoding::UndefinedConversionError "\xD0" from ASCII-8BIT to UTF-8

After googling around a bit the problem seems to lie in ruby 1.9.2 string handling but no real solution found.

I use magic_encoding to force utf-8 on all data. My database runs on utf-8 as well.

I'm running rails 3.1 and ruby 1.9.2.

Anyone that can shine some light on this error?


回答1:


You should add this line to the top of your .rb file

# encoding: utf-8

Or you can use this gem

magic_encoding

Related topic:

Add "# coding: utf-8" to all files



来源:https://stackoverflow.com/questions/7632473/encoding-error-while-writing-data-from-excelfile-to-database-mysql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!