我有兴趣使用 Ruby on Rails 3 创建一个希伯来语网站。问题是当我将希伯来语放入我的 View 时,我被告知它不受支持,我应该添加 UTF-8。
我已经在这方面工作了一段时间,但我似乎无法找到如何做到这一点。我也在使用 Sqlite3,我也想在那里保存希伯来语字符串。
我将如何实现这一目标?
我给出的错误代码是:Your template was not saved as valid UTF-8. Please either specify UTF-8 as the encoding for your template in your text editor, or mark the template with its encoding by inserting the following as the first line of the template:...
编辑:
问题是我在 Notepad++ 上工作,虽然它们是 UTF-8 格式的文件,但它没有以 UTF-8 格式保存我的文件。通过更改文件格式解决。
最佳答案
您应该尝试在 .rb
的第一行添加文件如下:
# encoding: utf-8
并在您的
.erb
的第一行<%# encoding: utf-8 %>
encoding: utf-8
和 coding: utf-8
并且是等价的。希望这可以帮助。
关于ruby-on-rails-3 - 如何在 Ruby on Rails 3 中允许从右到左的语言,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4866977/