开发者

acts_as_ferret with German umlauts

开发者 https://www.devze.com 2023-02-06 11:54 出处:网络
I managed to setup my app with a search based on acts_as_ferret. Overall it works fine. But I can\'t find results for words with umlauts (e. g. “Getränke”).

I managed to setup my app with a search based on acts_as_ferret. Overall it works fine. But I can't find results for words with umlauts (e. g. “Getränke”).

I added this to my environment.rb and rebuilt the index from scratch, but no better results.

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).

Then I opened the index file with Textmate to search for the entry with “Getränke” and I fugured, the TextM开发者_如何学编程ate opened it with Mac Roman encoding and display the Umlaut like this

Getr‰nke

I reopened the index file with UTF-8 encoding, but then the strange charackters are displayed as rectangles with questionmarks.

How can I find results by searching words with German umlauts?


This did the trick

environment.rb

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

database.yml

development:
  encoding: utf8
0

精彩评论

暂无评论...
验证码 换一张
取 消