Monday 30 July 2007

Characters encoding in HTML / PHP

In some cases, you could try whatever you like, it is impossible to change the default character encoding selection of a page. Why ? After almost 1h, I found out that the problem lies on the configuration of PHP, in the php.ini file where the default encoding character set was set to a different to the one I wanted to use.

To solve the problem, I have created a .htaccess file with the following line:

php_value default_charset "iso-8859-1"

This force the encoding to be iso=8859-1 when loading the PHP pages. I hope this might help you!

1 comment:

Jimmy said...

moi je met ça dans mes .htaccess pour être sûr que mes pages s'affichent bien, surtout quand on a du chinois dans la base de données : AddType 'text/html; charset=UTF-8' php

j'ai rajouté cette ligne après avoir passé des heures (le jour de la mise en prod) à chercher pourquoi le chinois était complètement illisible chez mon hébergeur alors que ça marchait nickel en local.