How To Pass A Latin1 Charset Associative Array From Php To Javascript?
The problem is that I have latin1 charset in db. The default output is utf-8 in php. even when i am using php iconv, it returns null as the new string is supposedly already utf-8.
Solution 1:
You could convert the encoding, prior to passing the data on to json_encode
(which really needs UTF8 encoded strings). Using the mb_convert_encoding
function will do:
$utf8String = mb_convert_encoding(
$sourceString,
'UTF8',
'<src encoding>' //in your case: ISO-8859-1
);
Meanwhile, work out a strategy of how you are going to convert your DB to UTF-8, because it'll save you a lot of pain endlessly juggling different encodings throughout your project.
Post a Comment for "How To Pass A Latin1 Charset Associative Array From Php To Javascript?"