PHP iconv encoding conversion problem!

Source: Internet
Author: User
    public function file_get(){        $file = file_get_contents('Curl.html');        iconv("ANSI", "UTF-8//IGNORE", $file);        return empty($file) ? null : $file;    }}header("Content-type: text/html; charset=utf-8");$url = new mycurl();$file = $url->file_get();echo strip_tags($file);

Curl.html as follows:

The output is as follows: (garbled!)

Notice:iconv (): Wrong charset, conversion from ' ANSI ' to ' utf-8//ignore ' are not allowed in D:\xampp\htdocs\function\funct  ion\curl\curl5.php on line 34http/1.1-OK Date:mon, 12:00:13 GMT server:ats/3.2.4 x-powered-by:php/5.3.9 Vary:accept-encoding content-type:text/html age:0 transfer-encoding:chunked proxy-connection:keep-alive via:http/1. 1 nxats01.ehomenet.com (apachetrafficserver/3.2.4 [CMSSF]) עйa {color: #333; text-decoration:none;} A: Hover, a:active, A:focus{color: #f00; text-decoration:underline;} img{border:0} body{margin:0px;font:12px ""; Background:url (http://static.sporttery.cn/info/roll/images/TopBg-ZQ.png) no-repeat;background-position:top Center}. Footer{width:1000px;line-height:22px;text-align:center;font-size:12px;color: #000000; margin-top:15px;}. Wrap{width:1000px;margin:auto;}. main{width:998px;border-left:1px #EEEEEE solid;border-right:1px #EEEEEE solid;background:url (HTTP// Static.sporttery.cn/info/roll/images/mainbg.gif) Repeat-x;background-position:top;float:left}. Mainleftbox{width:686px;margin-left:11px;display:inline;float:left}. mainrightbox{float:right;width:269px;margin:-30px 7px 0 0;}. Two_dot{width:686px;height:1px;background: #EBEBEB}. Yourposition{color: #333333; margin:6px 0 0 8px;height:24px}. Yourposition a{color: #333333;}. Yourposition a:hover{color: #FF0000;}. Dot{background:url (Http://static.sporttery.cn/info/roll/images/2_dot2.gif) repeat-x;width:686px;} /*banner1*/. banner{position:absolute;margin:1394px 0 0 6px;border:1px #000000 solid}/*banner2*/. banner2{width:984px;height:88px ;p osition:absolute;margin:2320px 0 0 6px;border:1px #006086 solid} *{font-size:12px;line-height:1.5em; wrap{width : 100%}. Banner,.footer, #main_nav,. Crumb form,.titlesc,.hideforprint{display:none;} crumb *{display:none;}. crumb{ text-align:left;font-weight:bold;line-height:26px; } table{width:100%;} table{border-collapse:collapse;} table th,table td{border:1px solid #333; line-height:1.2em;padding:2px; Width:auto;    }ʱ䣺01-29 15:43 [ˢ]й>>ע| Ȫ ׼¹׼׼ϻᱭ߱ Shi Ԥѡո׼ӣӣھ Ӣ׼עҳʾδϣ鿴ع̶ʤƽ Ҳ 桱 ȫͷ± VsͷԤƽֹʱѷ״̬עرʾ002¹׼˹ͼvsľ2014-01-30 02:59ѿ003 ϶ͷvsㅊ2014-01-30 02:59ѿ008ӣķȴvs˹س2014-01-30 03:44 Ѿ009dz˹vs 2014-01-30 03:44ѿܶܶ018ӣ׼ƶ˹vsʲ³˹2014-01-29 03:44ѿ001׼vsл2014-01-30 01:59ѿ004ӣ׼лƶvs ˵ñ2014-01-30 03:29ѿ005ӣɣvs˹п˳2014-01-30 03:44ѿ006ӣ˹άvs ķά2014-01-30 03:44ѿ007ӣжvsķ2014-01-30 03:44ѿ010ոvsŵ2014-01-30 03:44ѿδ:ʤƽ,ʤƽ011ոvs ʥ2014-01-30 03:44ѿ012 VS 2014-01-30 04:59ѿδ:ʤƽ, ʤƽ013߱vs 2014-01-30 07:59ѿ014߱ˮvsɾ2014-01-30 07:59 Ѿ001ӣھŵɭvsظ2014-01-31 03:44ѿ002ɣ̹¾vs ʼ2014-01-31 03:59ѿ003߱ѧvsɭ2014-01-31 06:59ѿ004߱˹vs  ŭ˹2014-01-31 09:14ѿעҳʾδϣ鿴ع̶ʤƽ net Ҳ 桱 match_counts (' 19 ');

Reply content:

    public function file_get(){        $file = file_get_contents('Curl.html');        iconv("ANSI", "UTF-8//IGNORE", $file);        return empty($file) ? null : $file;    }}header("Content-type: text/html; charset=utf-8");$url = new mycurl();$file = $url->file_get();echo strip_tags($file);

Curl.html as follows:

The output is as follows: (garbled!)

Notice:iconv (): Wrong charset, conversion from ' ANSI ' to ' utf-8//ignore ' are not allowed in D:\xampp\htdocs\function\funct  ion\curl\curl5.php on line 34http/1.1-OK Date:mon, 12:00:13 GMT server:ats/3.2.4 x-powered-by:php/5.3.9 Vary:accept-encoding content-type:text/html age:0 transfer-encoding:chunked proxy-connection:keep-alive via:http/1. 1 nxats01.ehomenet.com (apachetrafficserver/3.2.4 [CMSSF]) עйa {color: #333; text-decoration:none;} A: Hover, a:active, A:focus{color: #f00; text-decoration:underline;} img{border:0} body{margin:0px;font:12px ""; Background:url (http://static.sporttery.cn/info/roll/images/TopBg-ZQ.png) no-repeat;background-position:top Center}. Footer{width:1000px;line-height:22px;text-align:center;font-size:12px;color: #000000; margin-top:15px;}. Wrap{width:1000px;margin:auto;}. main{width:998px;border-left:1px #EEEEEE solid;border-right:1px #EEEEEE solid;background:url (HTTP// Static.sporttery.cn/info/roll/images/mainbg.gif) Repeat-x;background-position:top;float:left}. Mainleftbox{width:686px;margin-left:11px;display:inline;float:left}. mainrightbox{float:right;width:269px;margin:-30px 7px 0 0;}. Two_dot{width:686px;height:1px;background: #EBEBEB}. Yourposition{color: #333333; margin:6px 0 0 8px;height:24px}. Yourposition a{color: #333333;}. Yourposition a:hover{color: #FF0000;}. Dot{background:url (Http://static.sporttery.cn/info/roll/images/2_dot2.gif) repeat-x;width:686px;} /*banner1*/. banner{position:absolute;margin:1394px 0 0 6px;border:1px #000000 solid}/*banner2*/. banner2{width:984px;height:88px ;p osition:absolute;margin:2320px 0 0 6px;border:1px #006086 solid} *{font-size:12px;line-height:1.5em; wrap{width : 100%}. Banner,.footer, #main_nav,. Crumb form,.titlesc,.hideforprint{display:none;} crumb *{display:none;}. crumb{ text-align:left;font-weight:bold;line-height:26px; } table{width:100%;} table{border-collapse:collapse;} table th,table td{border:1px solid #333; line-height:1.2em;padding:2px; Width:auto;    }ʱ䣺01-29 15:43 [ˢ]й>>ע| Ȫ ׼¹׼׼ϻᱭ߱ Shi Ԥѡո׼ӣӣھ Ӣ׼עҳʾδϣ鿴ع̶ʤƽ Ҳ 桱 ȫͷ± VsͷԤƽֹʱѷ״̬עرʾ002¹׼˹ͼvsľ2014-01-30 02:59ѿ003 ϶ͷvsㅊ2014-01-30 02:59ѿ008ӣķȴvs˹س2014-01-30 03:44 Ѿ009dz˹vs 2014-01-30 03:44ѿܶܶ018ӣ׼ƶ˹vsʲ³˹2014-01-29 03:44ѿ001׼vsл2014-01-30 01:59ѿ004ӣ׼лƶvs ˵ñ2014-01-30 03:29ѿ005ӣɣvs˹п˳2014-01-30 03:44ѿ006ӣ˹άvs ķά2014-01-30 03:44ѿ007ӣжvsķ2014-01-30 03:44ѿ010ոvsŵ2014-01-30 03:44ѿδ:ʤƽ,ʤƽ011ոvs ʥ2014-01-30 03:44ѿ012 VS 2014-01-30 04:59ѿδ:ʤƽ, ʤƽ013߱vs 2014-01-30 07:59ѿ014߱ˮvsɾ2014-01-30 07:59 Ѿ001ӣھŵɭvsظ2014-01-31 03:44ѿ002ɣ̹¾vs ʼ2014-01-31 03:59ѿ003߱ѧvsɭ2014-01-31 06:59ѿ004߱˹vs  ŭ˹2014-01-31 09:14ѿעҳʾδϣ鿴ع̶ʤƽ net Ҳ 桱 match_counts (' 19 ');

$file = iconv("gbk", "UTF-8//IGNORE", $file);
This will be OK.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.