Rails 和 Ruby 1.9 中的无效多字节字符 (US-ASCII) [英] invalid multibyte char (US-ASCII) with Rails and Ruby 1.9
本文介绍了Rails 和 Ruby 1.9 中的无效多字节字符 (US-ASCII)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用 Ruby 1.9.1 和 Rails 2.3.4 我的应用程序是处理文本输入
I'm using Ruby 1.9.1 with Rails 2.3.4 My application is to handle text input
如果我尝试类似(内引号看起来不同)
If I try something like (the inside quotation marks look different)
text = """"
我收到以下错误:
#<SyntaxError: /Users/tammam56/rubydev/favquote/lib/daemons/twitter_quotes_fetch.rb:54: invalid multibyte char (US-ASCII)
/Users/tammam56/rubydev/favquote/lib/daemons/twitter_quotes_fetch.rb:54: invalid multibyte char (US-ASCII)
/Users/tammam56/rubydev/favquote/lib/daemons/twitter_quotes_fetch.rb:54: syntax error, unexpected $end, expecting keyword_end
我需要使用那些引号,因为用户可能会输入它们,而我必须考虑到这一点?
I need to user those quotation marks as users might input them and I have to account for that?
有什么想法吗?
推荐答案
您是否尝试过在使用非 ASCII 字符的脚本中添加魔法注释?它应该位于脚本之上.
Have you tried adding a magic comment in the script where you use non-ASCII chars? It should go on top of the script.
#!/bin/env ruby
# encoding: utf-8
它对我很有用.
这篇关于Rails 和 Ruby 1.9 中的无效多字节字符 (US-ASCII)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文