日期:2014-05-17  浏览次数:20512 次

使用fsockopen函数返回的里面有中文显示乱码
程序:

PHP code
            $domain = "6zhou.com";
            $whois_server = "whois.ename.com";
            $data = "";
            $fp = fsockopen($whois_server, 43, $errNo, $errStr, 55);
            if($fp)
            {
                fputs($fp, $domain. "\r\n");
                while (!feof($fp)) {
                    $data .= fgets($fp, 128);
                }
                fclose($fp);
                $data = nl2br(htmlentities($data));
                echo $data;
            }


运行结果显示:
Assembly code
Domain Name : 6zhou.com

Registrant : 
é?middot;æµ·å?micro;

Domain Name Server : 
dns1.iidns.com
dns2.iidns.com
dns3.iidns.com
dns4.iidns.com
dns5.iidns.com
dns6.iidns.com


æ?yen;ç湅å®?aelig;?acute;whois请å?deg;:http://whois.ename.net/6zhou.com
For more information,please go to: http://whois.ename.net/6zhou.com



注意里面有乱码字符,像这种情况应该怎么处理让它显示正常?

浏览器不管是使用utf8或gbk显示都没用

------解决方案--------------------
去掉 htmlentities 
或者给 htmlentities 指定合适的字符集名称