php - 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 但它没有用,有什么建议吗?
解决方案
对于那些面临同样问题的人,我在代码中添加了html_entity_decode()函数,以便解码我发送到数据库的数据:
$h2t = new html2text(html_entity_decode($leMessage));
然后显示它我使用:
mb_convert_encoding($h2t),"HTML-ENTITIES", 'UTF-8')
推荐阅读
- java - Android:检查 MediaRecorder 中使用的 HW Encoder 或 SW Encoder
- unreal-engine4 - 在虚幻中平滑增加角色的速度
- node.js - NodeJS获取表单没有返回任何东西
- ruby-on-rails - 编辑嵌套的属性/模型导轨
- python - python中的记忆硬币变化(递归解决方案)
- node.js - Google V2 Node.js 上的操作 - 尝试使用 conversation.data 但它没有按预期工作
- ubuntu - 无法在 Ubuntu 18.04 LTS 上安装 Parallels Tools
- ios - 为什么我的设备显示与模拟器不同的自动布局?
- airflow - 如果任何任务失败,如何将 Airflow DAG 运行标记为失败?
- scala - 为什么这个柯里化函数的函数定义在 scala 中不起作用?