utf 8 - Convert Japanese characters to UTF-8 for php json_encode -
i have japanese string in (utf-8 encoded) database '利用規約' passed php's json_encode function , receive warning:
php warning: json_encode(): invalid utf-8 sequence in argument
is there way convert valid utf-8 in order avoid this? if db utf-8 why php have problem string?
update:
turns out error in fact due problem sprintf , multibyte characters couple lines earlier.
utf8_encode should work you.
http://www.php.net/manual/en/function.utf8-encode.php
if utf8_encode doesn't work, try mb_convert_encoding:
mb_convert_encoding($string,"utf-8","auto");
Comments
Post a Comment