I'm trying to process an array of tweets using array_walk encode the text into UTF8 so that any chinese characters are handled properly.
array_walk($tweet_data, function(&$tweet, $key) {
$tweet['text'] = iconv('Windows-1250', 'UTF-8', $tweet['text']);
});
When I do this, I get the error "Detected an illegal character in input string"
I've also tried this using utf8_encode.
array_walk($tweet_data, function(&$tweet, $key) {
$tweet['text'] = utf8_encode($tweet['text']);
});
And this passes through without any issue, but when the text is then displayed on the page, the characters are all wrong.
How can I properly handle UTF8 characters before passing into json_encode so it doesn't break?
json_encode($array, JSON_UNESCAPED_UNICODE)