Heroku控制台给出了Encoding :: UndefinedConversionError

时间:2013-04-09 16:36:24

标签: ruby-on-rails-3 heroku encoding irb

使用

运行heroku控制台
heroku run console

所有返回UTF-8字符的命令(如德语变音符号)都会导致以下错误:

irb(main):004:0> Play.all[-2]
   Play Load (27.5ms)  SELECT "plays".* FROM "plays" ORDER BY name asc 
Encoding::UndefinedConversionError: U+00E4 from UTF-8 to US-ASCII
    from /usr/local/lib/ruby/1.9.1/irb.rb:311:in `write'
    from /usr/local/lib/ruby/1.9.1/irb.rb:311:in `printf'
    from /usr/local/lib/ruby/1.9.1/irb.rb:311:in `output_value'
    from /usr/local/lib/ruby/1.9.1/irb.rb:160:in `block (2 levels) in eval_input'
    from /usr/local/lib/ruby/1.9.1/irb.rb:273:in `signal_status'
    from /usr/local/lib/ruby/1.9.1/irb.rb:156:in `block in eval_input'
    from /usr/local/lib/ruby/1.9.1/irb/ruby-lex.rb:243:in `block (2 levels) in each_top_level_statement'
    from /usr/local/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in `loop'
    from /usr/local/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in `block in each_top_level_statement'
    from /usr/local/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in `catch'
    from /usr/local/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in `each_top_level_statement'
    from /usr/local/lib/ruby/1.9.1/irb.rb:155:in `eval_input'
    from /usr/local/lib/ruby/1.9.1/irb.rb:70:in `block in start'
    from /usr/local/lib/ruby/1.9.1/irb.rb:69:in `catch'
    from /usr/local/lib/ruby/1.9.1/irb.rb:69:in `start'
    from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/commands/console.rb:47:in `start'
    from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/commands/console.rb:8:in `start'
    from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'Maybe IRB bug!!

我真的不明白这个原因。 有解决方法吗?

我使用的是iTerm,设置为“UTF-8 xterm-color”。

更新

这个错误完全消失了,因为我没有找到任何理由,我也无法在ruby 1.9.2p320和1.9.3p448下重现它 现在在控制台中键入“\ u00E4”会产生“ä”,如预期的那样:

irb(main):001:0> "\u00E4"
=> "ä"

0 个答案:

没有答案