符号错误在urlencode, PHP


Symbols bug in urlencode, PHP

我目前正在为从doc文件生成的html文件编写解析器。字符串包含像alpha beta等符号…问题是,当我做一个urldecode(urlencode(alpha));时,它没有给出符号…它返回别的东西

要找到我的问题,请查看

urldecode("%0A%20%20If%20%3Ci%20style%3D%22mso-bidi-font-style%3Anormal%22%3E%CE%B1%3C%2Fi%3E%2C%20b%2C%20g%0A%20%20be%20the%20zeroes%20of%20the%20polynomial%20%3Ci%20style%3D%22mso-bidi-font-style%3Anormal%22%3Eax%3C%2Fi%3E%3Csup%3E3%3C%2Fsup%3E%0A%20%20%2B%20b%3Ci%20style%3D%22mso-bidi-font-style%3Anormal%22%3Ex%3C%2Fi%3E%3Csup%3E2%3C%2Fsup%3E%20%2B%20c%3Ci%20style%3D%22mso-bidi-font-style%3Anormal%22%3Ex%3C%2Fi%3E%20%2B%20d%2C%20the%20the%20value%20of%20%3Ci%20style%3D%22mso-bidi-font-style%3Anormal%22%3E%26nbsp%3B%CE%B1%3C%2Fi%3Eb%20%2B%20bg%20%2B%20g%3Ci%20style%3D%22mso-bidi-font-style%3Anormal%22%3E%20%CE%B1%3C%2Fi%3E%26nbsp%3B%20is%0A%20%20");

有办法解决这个问题吗?

您的字符集不匹配。该符号可能被解码为UTF-8,但您将该站点解释为其他内容,例如Latin-1。要确认这一点,请从浏览器的View> Encoding菜单中选择UTF-8。设置一个适当的标题,使网站总是使用UTF-8:

header('Content-Type: text/html; charset=utf-8');

这意味着您还需要确保您的网站的其余部分是有效的UTF-8,否则匹配您的文本的编码。

You can used javascript function  unescape($urlfordecode);
Its decode your url, if you want to mannually check then used following url
http://meyerweb.com/eric/tools/dencoder/

php 使用以下代码
  $urlfordecode ="Your encoded url place here";
    $a = explode('&', $urlfordecode);
    $i = 0;
    while ($i < count($a)) {
        $b = explode('=', $a[$i]);
        echo 'Your decoded url is  =>  </br>',htmlspecialchars(urldecode($b[0])), 
        htmlspecialchars(@urldecode($b[1])), "<br />'n";
        $i++;
    }