Encoding error while writing data from excelfile t

2019-05-22 20:19发布

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条回答
乱世女痞
2楼-- · 2019-05-22 21:03

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

查看更多
登录 后发表回答