首页 > 解决方案 > html2text 结果删除了一些特殊字符

问题描述

我正在尝试使用 html2text 函数显示一条消息,结果以 utf-8 编码,唯一的问题是在某些情况下,字符会从单词中删除。

示例:我得到nhsitez而不是n'hésitez,这是我的代码

$h2t = new html2text($leMessage);
$altBody = $h2t->get_text();
logMessagePreformate($id_dossier, utf8_decode($sujet),$altBody, $pour1, $pour2);

我尝试了 utf8_encode 和 mb_convert_encoding 但它没有用,有什么建议吗?

标签: php

解决方案


对于那些面临同样问题的人,我在代码中添加了html_entity_decode()函数,以便解码我发送到数据库的数据:

$h2t = new html2text(html_entity_decode($leMessage));

然后显示它我使用:

mb_convert_encoding($h2t),"HTML-ENTITIES", 'UTF-8')


推荐阅读