I have a problem utf8 encoding. In the wordpress database, there are many emojis but when I encode, they no longer appear. There is a "?" instead that appears.
Can you help me ? I think it comes from utf8_encode
here is the code :
$results = $connection->query($req) or die(Array());
$results->setFetchMode(PDO::FETCH_OBJ);
$i = 0;
$jsonArray = Array();
while($row = $results->fetch()) {
$jsonArray[$i][0] = utf8_encode($row->comment_author);
$jsonArray[$i][1] = utf8_encode(nl2br($row->comment_content));
$jsonArray[$i][2] = utf8_encode($row->comment_date);
$jsonArray[$i][3] = utf8_encode($row->replyingToAuthor);
$jsonArray[$i][4] = utf8_encode($row->comment_ID);
++$i;
}
$results->closeCursor();
$connection = NULL;
echo json_encode($jsonArray);
This is the line that displays the comment:
$jsonArray[$i][1] = utf8_encode(nl2br($row->comment_content));
I have no problem with encoding accents, only with emoji
Thank you
This is what I did to solve this:
Create a function
Call the function