Magento: Solving French Character Display Issues
Hello developers! Today, we’re going to tackle a common issue that many Magento users face - displaying French characters correctly within their storefronts.
The Problem
You’ve probably encountered this yourself - your Magento installation seems to use UTF-8 by default (as it should), but certain French characters just won’t display properly. Instead of the intended text:
Vous aimerez peut-être aussi
You end up with something like this:

This is frustrating, especially when other UTF-8 sites like StackOverflow can display these characters without issue.
The Typical Approach and Why It Fails
Many developers try to change the default character encoding by modifying the app/code/core/Mage/Page/etc/config.xml file:
<default_charset>ISO-8859-1</default_charset>
They hope this will solve their problem, but it doesn’t. Even after changing the encoding and refreshing the page, Firefox still displays the incorrect characters:

The Root Cause
The issue often lies in how your PHP code is generating these French texts. If you’re using Eclipse to edit .phtml files and these texts are being created dynamically via PHP, the problem might be with the encoding settings within your IDE or server configuration.
The Solution: Setting Up UTF-8 Properly
To resolve this, we need to ensure that every part of our Magento installation is set up to handle UTF-8 characters correctly:
1. MySQL Configuration
First, check if your MySQL database is using UTF-8. You can verify this by running the following query in phpMyAdmin or any other SQL client:
SHOW VARIABLES LIKE 'collation_database';
The collation_database should be set to a UTF-8 variant (e.g., utf8_general_ci).
2. PHP Configuration
Next, ensure that your PHP configuration is set to handle UTF-8 data properly:
default_charset = "UTF-8"
Add this line to your php.ini file or the .htaccess file in your Magento root directory.
3. File Encoding
Finally, ensure that all your Magento files (including .phtml, .xml, and others) are saved with UTF-8 encoding without BOM (Byte Order Mark). In Eclipse, you can do this by right-clicking on the file and selecting Properties > Resource > Text file encoding and setting it to UTF-8.
Conclusion
In most cases, when French characters aren’t displaying properly in Magento, the solution lies in ensuring that every component of your installation - from MySQL to PHP configuration to file encoding - is set up correctly for UTF-8 handling.
Remember, Magento is designed to work with UTF-8 out-of-the-box. If you’re still having issues after following these steps, double-check that there are no conflicting encoding settings anywhere in your server or application.
If you find yourself needing more advanced help with Magento development, feel free to reach out to the experts at Laravel Company. We specialize in delivering top-notch eCommerce solutions tailored to your business needs.