# Find\_by\_ferret and UTF-8

**URL:** <https://www.ruby-forum.com/t/find-by-ferret-and-utf-8/161872>\
**Category:** Ferret\
**Created:** [March 3, 2009, 9:38am UTC](https://www.ruby-forum.com/t/find-by-ferret-and-utf-8/161872 "2009-03-03T09:38:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![indigoi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/b3f665/32.png) [@indigoi](https://www.ruby-forum.com/u/indigoi)\
**Post date:** [March 3, 2009, 9:38am UTC](https://www.ruby-forum.com/t/find-by-ferret-and-utf-8/161872/1 "2009-03-03T09:38:17Z")

</div>

Hi all,

So I scoured the Internet and it’s possible I read the answer but didn’t  
know I was looking at it (because I am beginning programmer) but if  
someone could explain this it would be much appreciated. The problem is  
I am having trouble finding a UTF-8 term with the find\_by\_ferret method.

I am using  
ruby 1.8.6 (2008-03-03 patchlevel 114) [x86\_64-linux]  
Rails 2.2.2  
ferret (0.11.6)  
acts\_as\_ferret (0.4.3)

In my controller I have @results =  
Product.find\_with\_ferret(params[:query])  
I have a single product called “sony æ•°”  
In my model I have acts\_as\_ferret :fields =\> { :name =\> { :store =\> :yes  
}}

I am able to use my Rails app to obtain a successful hit on the index  
when :query =\> “sony” but no luck when :query =\> “æ•°”

Debug steps:

1. So using ferret-browser, I have confirmed that this document is in  
the index and so are the terms “sony” and “æ•°”. So I know it’s not a  
ferret issue. This leaves Rails and acts\_as\_ferret

2. when I switch my controller to @results =  
[Product.find\_by\_name(params[:query])]  
I am able to find the product so it seems it is not a Rails issue.

3. A bunch of blogs say use $KCODE=‘u’ and require ‘jcode’ in  
environment.rb but they seem to be outdated because it appears that  
$KCODE=‘u’ is already hardcoded into initializer.rb and isn’t the Chars  
class in Rails supposed to wrap String nicely, so that jcode isn’t  
needed anymore?

4. If the answer lies here [http://rm.jkraemer.net/wiki/aaf#13](http://rm.jkraemer.net/wiki/aaf#13)  
I can’t tell what I am supposed to do. They seem like a bunch of  
solutions to problems that are not similar to mine.

5. Lastly, it seems like Ruby 1.8.6 recognizes UTF-8 based on following  
the examples here  
[http://blog.grayproductions.net/articles/the\_kcode\_variable\_and\_jcode\_library](http://blog.grayproductions.net/articles/the_kcode_variable_and_jcode_library)  
Not sure I understand why I have to use 1.9.

fyi, æ•° is equivalently %E6%95%B0 in UTF-8 and I tried passing :query =\>  
“%E6%95%B0” and no luck either.

Thank you,  
Richard
