开发者

How do I change my default charset from ANSI to Unicode in my project?

How do I change my default charset from ANSI to Unicode in my project? When I write special characters as Æ Ø Å in my view that is ANSI it renders a error. But if I change the file to UTF-8 encoding it renders the special characters without a error. Should I then change all my view files from ANSI encoding to U开发者_如何转开发TF-8 ?


Here is some rails magic - add this comment to your .rb file:

# coding: utf-8

and it should work)

You also can use Iconv class to convert your string to UTF-8 like this:

require 'iconv'
ic = Iconv.new('WINDOWS-1251','UTF-8')
new_string = ic.iconv(old_string)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜