Force encoding in utf-8 for a php page

apache, debian, encoding, php, utf-8

Solution

Your response header is incorrect:

header('Content-type: application/json; charset: UTF-8');

It should be:

header('Content-type: application/json; charset=UTF-8');

Notice the `=` in place of `:`

Problem

I have a VPS (Debian, Apache, MySQL, PHP) I want to force the encoding in UTF-8. I have put this line : ``` header('Content-type: application/json; charset: UTF-8'); ``` But the charset is still ISO8859 I also edited the php.ini : /etc/php5/apache2/php.ini ``` mbstring.language=UTF-8 mbstring.internal_encoding= UTF-8 mbstring.http_input=UTF-8 mbstring.http_output=UTF-8 mbstring.detect_order= auto ``` and the apache conf : ``` nano /etc/apache2/conf.d/charset AddDefaultCharset UTF-8 ``` An iOS application is calling my php page. And I give it a JSON output. But it receives ISO charset...

Original source