Reputation: 8336
I receive a response from a web service, and the values are ISO-8859-1 encoded. The supplied library converts the response to an array, and I am using json_encode
to serialize the response and store it in the database. It's a MySQL database, InnoDB engine, with a UTF8 character set.
The encoding issue revealed itself by this warning in my log:
PHP Warning: json_encode(): Invalid UTF-8 sequence in argument in...
I know the array key values are alright because they're always the same and I don't see the warning for every request.
Is there any downside to using array_map
with utf8_encode
to get rid of the warnings?
json_encode(array_map('utf8_encode', $response))
Upvotes: 0
Views: 967