» tagged pages
» logout

sorted by: recent | see : popular
Content Tagged with character + Development

French Characters Not Rendering Correctly

Background Knowledge
The MySQL database v4.0.23 is using the default character set of “Latin1″. When the database was created I had no knowledge of character sets other wise it would have been “UTF-8″.
The web pages are using a character set of “UTF-8″.

Problem
Data being queried from a MySQL database that contains French accent characters will not render correctly in the browser even after applying PHP htmlentities().

Example code: $string = htmlentities($string , ENT_QUOTES, “UTF-8″);

Solution
The queried data from the database was inputted using the character set “ISO-8859-1″. I found this out by changing the browser’s character encoding to “Western ISO-8859-1″ and the French accent characters then rendered properly. With the use of PHP iconv() I was able to convert the data from “ISO-8859-1″ to “UTF-8″ character set and the French characters then rendered properly in the browser.

Example code: $string = iconv(”ISO-8859-1″,”UTF-8″,”$string”);


If you are unaware of what MySQL default character set being used, you can run this SQL command “show variables like “%character%” and check your MySQL configuration file. Refer to the MySQL manual for further details.

MySQL: Planet MySQL

XHTML Character Entity Reference

ReferĂȘncia de entidades para XHTML e XML

XML: del.icio.us/tag/xml

HTML Character Codes—Sidebar for Firefox/Opera

Entity codes reference; can be used as a sidebar panel in Firefox or Opera for quick reference.

Firefox: del.icio.us/tag/firefox