invalid multibyte char (US-ASCII) ruby1.92011-03-17
ruby1.9+rails3在helper方法中写中文时,出现 invalid multibyte char (US-ASCII) 异常了,查了下,原来ruby1.9是用ASCII编码来读源码的,奇怪。
解决办法是在文件的第一行加上
# encoding: utf-8
rails3中确定application.rb中有:
# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"
阅读下面的文章:
http://blog.grayproductions.net/articles/ruby_19s_three_default_encodings
http://blog.grayproductions.net/articles/understanding_m17n