我正在使用 Sinatra 构建一个应用程序。该应用程序运行良好,除非我最近将一个元素添加到具有特殊字符 (Yóü) 的数组中。
@peeps = ["Joe", "James", "Phil", "Jane", "Yóü"]
我将这个数组用于许多事情,但我不确定是否需要将它们包含在这篇文章中。当我运行我的应用程序时,我的浏览器中出现以下错误:
Internal Server Error: invalid byte sequence in US-ASCII
在我的终端窗口中,我在运行后看到以下内容ruby app.rb
app.rb:34: invalid multibyte char (US-ASCII)
app.rb:34: invalid multibyte char (US-ASCII)
app.rb:34: syntax error, unexpected $end, expecting ']'
此外,为了它的价值,我通常使用shotgun来运行我的服务器,因为我可以进行更改并刷新页面。当我运行时显示此错误shotgun app.rb
[2012-08-16 21:36:37] ERROR ArgumentError: invalid byte sequence in US-ASCII
/Users/me/.rvm/gems/ruby-1.9.3-p125@rails3tutorial2ndEd/gems/rack-1.4.1/lib/rack/utils.rb:182:in `gsub'
/Users/me/.rvm/gems/ruby-1.9.3-p125@rails3tutorial2ndEd/gems/rack-1.4.1/lib/rack/utils.rb:182:in `escape_html'
/Users/me/.rvm/gems/ruby-1.9.3-p125@rails3tutorial2ndEd/gems/shotgun-0.9/lib/shotgun/loader.rb:76:in `format_error'
/Users/me/.rvm/gems/ruby-1.9.3-p125@rails3tutorial2ndEd/gems/shotgun-0.9/lib/shotgun/loader.rb:52:in `proceed_as_parent'
/Users/me/.rvm/gems/ruby-1.9.3-p125@rails3tutorial2ndEd/gems/shotgun-0.9/lib/shotgun/loader.rb:28:in `call!'
/Users/me/.rvm/gems/ruby-1.9.3-p125@rails3tutorial2ndEd/gems/shotgun-0.9/lib/shotgun/loader.rb:18:in `call'
/Users/me/.rvm/gems/ruby-1.9.3-p125@rails3tutorial2ndEd/gems/shotgun-0.9/lib/shotgun/favicon.rb:12:in `call'
/Users/me/.rvm/gems/ruby-1.9.3-p125@rails3tutorial2ndEd/gems/shotgun-0.9/lib/shotgun/static.rb:14:in `call'
/Users/me/.rvm/gems/ruby-1.9.3-p125@rails3tutorial2ndEd/gems/rack-1.4.1/lib/rack/builder.rb:134:in `call'
/Users/me/.rvm/gems/ruby-1.9.3-p125@rails3tutorial2ndEd/gems/rack-1.4.1/lib/rack/handler/webrick.rb:59:in `service'
/Users/me/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/Users/me/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/Users/me/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'