简体   繁体   English

acts_as_ferret与德国变音符

[英]acts_as_ferret with German umlauts

I managed to setup my app with a search based on acts_as_ferret. 我设法通过基于act_as_ferret的搜索来设置我的应用。 Overall it works fine. 总体来说,它工作正常。 But I can't find results for words with umlauts (eg “Getränke”). 但是我找不到带有变音符号的单词的结果(例如“Getränke”)。

I added this to my environment.rb and rebuilt the index from scratch, but no better results. 我将此添加到我的environment.rb并从头开始重建索引,但没有更好的结果。

Ferret.locale = "de_DE.UTF-8"

I double checked my database table, but I think this should be perfect: 我仔细检查了数据库表,但是我认为这应该是完美的:

DEFAULT CHARSET=utf8 COLLATE=utf8_bin

BTW: The data is displayed fine in the database table (viewed with Sequel Pro). 顺便说一句:数据在数据库表中正常显示(使用Sequel Pro查看)。

Then I opened the index file with Textmate to search for the entry with “Getränke” and I fugured, the TextMate opened it with Mac Roman encoding and display the Umlaut like this 然后,我使用Textmate打开索引文件,以“Getränke”搜索条目,然后将其置为假,TextMate使用Mac Roman编码将其打开并显示Umlaut

Getr‰nke 格特朗克

I reopened the index file with UTF-8 encoding, but then the strange charackters are displayed as rectangles with questionmarks. 我用UTF-8编码重新打开了索引文件,但随后奇怪的字符显示为带有问号的矩形。

How can I find results by searching words with German umlauts? 如何通过搜索带有德语变音符号的单词来找到结果?

This did the trick 这成功了

environment.rb environment.rb

$KCODE = 'u'
ENV['LANG'] = 'de_DE.UTF-8'
Ferret.locale = "de_DE.UTF-8"

database.yml 数据库

development:
  encoding: utf8

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM