utf8_encode和表情符号 [英] utf8_encode and Emoji

查看:132
本文介绍了utf8_encode和表情符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的utf8编码有问题。在wordpress数据库中,有很多表情符号,但是当我编码时,它们不再出现。有一个?

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.

你能帮我吗?我认为它来自utf8_encode

Can you help me ? I think it comes from utf8_encode

这是代码:

$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);

这是显示注释的行:

 $jsonArray[$i][1] = utf8_encode(nl2br($row->comment_content));

我对口音编码没有问题,只有表情符号

I have no problem with encoding accents, only with emoji

谢谢

推荐答案

我改进了它,因为它没有用。

I improve that, because it didnt't work.

函数:

function formatoAcentos($texto) {
$nvotexto = nl2br($texto);          // permite mantener el salto de línea
$nvotexto = utf8_encode($nvotexto); // permite caracteres especiales como los acentos
return $nvotexto;
}

函数调用。

echo formatoAcentos($row['descripcion_doc'])

这篇关于utf8_encode和表情符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆