qua*_*ain 2 ruby string ruby-1.9
我有很多这些代码行:
@breadcrumb = []
@breadcrumb << ["#!", "Hlada?"]
Run Code Online (Sandbox Code Playgroud)
它是在ruby ree-1.8中,但我可以将其更改为1.9,但我有这个错误:
/app/controllers/index_controller.rb:36: syntax error, unexpected $end, expecting ']'
@breadcrumb << ["#!", "Hlada?"]
Run Code Online (Sandbox Code Playgroud)
当我删除"ť"和其他特殊字符(ľščťžýáí...)时它没问题,但我需要这些字符.
将指定编码的"魔术注释"添加到每个具有非ASCII字符的Ruby文件的顶部:
# encoding: UTF-8
Run Code Online (Sandbox Code Playgroud)
在config.encoding
正确设置的Rails视图文件中不需要这样(默认为UTF-8).您还应该阅读有关Ruby 1.9的编码行为的更多信息.