【问题标题】:phpQuery and accented charsphpQuery 和重音字符
【发布时间】:2012-06-06 19:57:20
【问题描述】:

当我使用 phpQuery 解析 html 时,我得到了带有重音字符的糟糕结果。 以下代码回显胡扯...

<?php 
    require_once 'phpQuery.php';
    $dom = phpQuery::newDocumentHTML('<p>é</p>');
    echo $dom->text(); //bad result
?>

有人知道 phpQuery 中的重读吗?

我在带有 firefox 的 windows 2008 服务器上使用 netbeans。

【问题讨论】:

    标签: php phpquery non-ascii-characters


    【解决方案1】:

    尝试在您的页面上添加:

    header("Content-Type:text/html; charset=UTF-8");
    

    欢迎您!

    顺便说一句,我相信你使用的是 Windows 2008 Server 而不是 Windows 7 Server ...

    【讨论】:

    【解决方案2】:

    试试看:

    echo htmlspecialchars($dom->text());
    

    【讨论】:

      【解决方案3】:

      你试过了吗

      string utf8_decode ( string $data )
      

      string utf8_encode ( string $data )
      

      我相信我之前的回答一定是 UTF-8 问题。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-12-02
        • 2017-06-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-11-05
        • 2023-03-03
        • 1970-01-01
        相关资源
        最近更新 更多