Q:

Convert Japanese characters to UTF-8 for php json_encode

I have a Japanese string in my (UTF-8 encoded) database '利用規約' which is passed to php's json_encode function and receive this warning:
PHP Warning:  json_encode(): Invalid UTF-8 sequence in argument
Is there a way to convert this to valid UTF-8 in order to avoid this?  If the db is utf-8 why would php have a problem with the string?
Update:
Turns out the error was in fact due to a problem with sprintf and multibyte characters a couple lines earlier.

A:

utf8_encode should work for 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");

