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 rails...@googlegroups.com.
To unsubscribe from this group, send email to rails-i18n+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rails-i18n?hl=en.
Ok I will take your advise and remove the html entities from the
database.
The reason I put them in was because even with explicit encoding I was
not getting the characters to show properly. I was getting a black
triangle with a question mark.
Could you assist me on how to encode the web page so that it shows the
accents. I thought you just use UTF-8?
Thanks for your help. I really appreciate it.
Ok I will take your advise and remove the html entities from the
database.
The reason I put them in was because even with explicit encoding I was
not getting the characters to show properly. I was getting a black
triangle with a question mark.
Could you assist me on how to encode the web page so that it shows the
accents. I thought you just use UTF-8?
Now instead of "électronique" I get name: "\xC9lectronic" where
the"\xC9" displays like a black triangle with a "?" in it.
I also changed the font to times.
I read up and learned that MYSQL might be delivering the characters in a
format other than UTF-8.
I changed my database, table, and field to be UTF-8.
I still get the same problem as stated above.
What gives?
Thanks in advance
MItch
using utf8 encoding by putting the following in the database.yml file
encoding: utf8
now it displays perfectly.
I hope this is still in line with best practices as I don't want to mess
this up again.
Thanks
MItch