I am trying to search my database which has product names with french
accents.  They are encoded using the html entity codes such as &eactue;
etc.

If a user enters a word with a french accent in the search box I must
convert it to the html entity code so it can be found in the database.

So I thought to use str.sub(pattern, replacement) => new_str

However when I try this using product.sub('é','é') for example it
results in the following:

find(:all, :select => 'product_id, name', :order => "name", :conditions
=> ["name like ? and locale =?", "%#{product.sub('é','é')}%",
I18n.locale])

When I enter 'é' in the seach box I get the following:

   SELECT product_id, name FROM `product_descriptions` WHERE (name like
'%é%' and locale ='en')

so it does not replace the 'é' with '&eactue'

But if  I change the letter from 'é' to 'e'  and do a search for 'e' I
get the following:

   SELECT product_id, name FROM `product_descriptions` WHERE (name like
'%é%' and locale ='en')

so the replacement works.

Can anyone explain why it won't work for the character with french
accent?

Thank you in advance.
Mitch

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups 
"rails-i18n" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rails-i18n?hl=en.

Reply via email to