1

运行一个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!!

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

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

更新

这个错误在我不知道的原因下完全消失了,我无法在 ruby​​ 1.9.2p320 或 1.9.3p448 下重现它现在在控制台中键入“\u00E4”会产生“ä”,如预期的那样:

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

0 回答 0