I have created a rails application, in which I am displaying any type of name, name can be anything from person, cars, vegetables, any material.
So I thought of including some ingredient name like Crème Fraîche, whenever I copy this name from other web page and store in my database, it properly stores it.
While displaying this name on web page, I get some strange characters appearing on the page like Cr�me Fra�che.
I have used charset UTF-8, then also it displays the name like this.
I checked in my database name is stored properly, but on page and in irb it displays the name like this.
I have wasted nearly 5 days on searching for the above problem but didn't succeed. I hope this time I will get some help
Thanks in advance Pankaj
include the following meta tag in the section of your page
This tells browsers to use ISO encoding to interpret the text on the page
Even with the correct encoding in the webpage, characters will still display corrupted on a machine where the required fonts are not installed and obviously you cannot be sure what fonts are installed on machines looking at your page
Browsers may also need to be configured. For example, Firefox needs to be told in the Options/Tools/Content section to use the above character set by default
To be absolutely certain your characters will display correctly use the unambiguous HTML code for each non-standard character e.g. instead of Crème use Cr & egrave ; me (NB there should not be spaces between the "&" and the ";" - I had to type it in this way to stop this page from interpreting the code and displaying è).
This can have implications for web searches and ordering functions in your database. You could store the text as Crème in your database and pass everything through a conversion function before delivering to the HTML page (this will obviously introduce a slight delay in fetching the page). You might also consider having two versions of your data, a raw data version and a display version. Then you could pass new data through the conversion function, store the converted version and have the converted data written to the HTML page.