UTF-8 encoding with json_encode
Posted: Mon Jun 01, 2009 11:16 am
Hey all.
Using some JSON to pass data using AJAX - running into issues where the encoding just stops abruptly when it encounters this text:
"...in São Paulo..."
This bug suggests it's not just me: http://bugs.php.net/bug.php?id=43941
I can't upgrade my php install on this server so does anyone have any alternatives? This content is coming from a database and may contain foreign characters frequently. I read somewhere else about using utf8_encode but this breaks the HTML I'm passing through the JSON (eg, a </h1> tag becomes <\/h1> and messes up my styling) - any tips? If it helps, the webpage itself is encoded in ISO-8859-1 (although changing it to UTF-8 through Firefox doesn't seem to help).
Using some JSON to pass data using AJAX - running into issues where the encoding just stops abruptly when it encounters this text:
"...in São Paulo..."
This bug suggests it's not just me: http://bugs.php.net/bug.php?id=43941
I can't upgrade my php install on this server so does anyone have any alternatives? This content is coming from a database and may contain foreign characters frequently. I read somewhere else about using utf8_encode but this breaks the HTML I'm passing through the JSON (eg, a </h1> tag becomes <\/h1> and messes up my styling) - any tips? If it helps, the webpage itself is encoded in ISO-8859-1 (although changing it to UTF-8 through Firefox doesn't seem to help).