Question

I had problem encoding traditional/simplified Chinese character with php. I've done quite some research but

mysql_set_charset('utf8');
header("content-type:text/html; charset=utf8");

didn't work for me

Was it helpful?

Solution 2

Found the following answer works for me.

Traditional Chinese

    mysql_set_charset('big5');
    header("content-type:text/html; charset=big5");

    $stack = array();
    $data = array("id" => $row[0], "name" => urlencode("台灣"));
    array_push($stack, $data);
    $json = urldecode(json_encode($stack));
    echo $json;

Simplified Chinese

change the 'big5' to 'gbk'

OTHER TIPS

use this code on top of your page:

header('Content-Type: text/html; charset=utf-8');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top