J’ai un VPS (Debian, Apache, MySQL, PHP)
Je veux forcer l’encodage en UTF-8. J’ai mis cette ligne:
header('Content-type: application/json; charset: UTF-8');
Mais le charset est toujours ISO8859
J’ai aussi édité le php.ini: /etc/php5/apache2/php.ini
mbssortingng.language=UTF-8 mbssortingng.internal_encoding= UTF-8 mbssortingng.http_input=UTF-8 mbssortingng.http_output=UTF-8 mbssortingng.detect_order= auto
et la confession apache:
nano /etc/apache2/conf.d/charset AddDefaultCharset UTF-8
Une application iOS appelle ma page PHP. Et je lui donne une sortie JSON. Mais il reçoit le jeu de caractères ISO …
Votre en-tête de réponse est incorrect:
header('Content-type: application/json; charset: UTF-8');
CA devrait etre:
header('Content-type: application/json; charset=UTF-8');
Notez le =
à la place de :
Avez-vous examiné la fonction utf8-encode
: http://php.net/manual/en/function.utf8-encode.php ?
Vous pouvez faire écho au texte non correctement encodé au client. Apache ne le fait pas pour vous.
Dans le fichier .htaccess, vous pouvez mettre:
php_value default_charset UTF-8