首页 > 解决方案 > 将 t 转换为 php 中的撇号

问题描述

我正在从另一个系统中提取一些文本,该系统已从 Word 或其他系统中粘贴了文本。

有时撇号与这些字符一起显示。我可以进行搜索和替换,但我确信这不是最好的方法,因为可能还有其他字符的行为方式类似。

我看过这个问题 [ Getting ’ instead of an apostrophe(') in PHP但我尝试过的一切仍然不起作用。

我的简化代码是这样的。

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf8_unicode_ci" />
    <title></title>
</head>
<body>
    <?php

    $s = "It’s Getting the Best of Me";

    echo $s . "<br>";

    $notGiberish = mb_convert_encoding($s, "HTML-ENTITIES", 'UTF-8');

    echo $notGiberish . "<br>";
    echo html_entity_decode(mb_convert_encoding($s, "HTML-ENTITIES", 'UTF-8')) . "<br>";
    ?>
</body>

如果必须,我将搜索和替换。

谢谢

标签: phputf-8

解决方案


推荐阅读