I m calling json_encode()
on data that comes from a MySQL database with utf8_general_ci
collation. The problem is that some rows have weird data which I can t clean. For example symbol �
, so once it reaches json_encode()
, it fails with json_encode(): Invalid UTF-8 sequence in argument
.
I ve Trial utf8_encode(
> and utf8_decode(<>/code>, 即便有
mb_check_encoding(<>
,但通过并造成严重破坏。
Running PHP 5.3.10 on Mac. So the question is - how can I clean up invalid utf8 symbols, keeping the rest of data, so that json_encoding()
would work?
更新。 这里可以复制:
echo json_encode(pack("H*" , c32e ));