Iconv encoding conversion in php!

Source: Internet
Author: User
Example code ..w.curl.html is as follows: (garbled !) {Code ...}
    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 is as follows:

Output: (garbled !)

Notice: iconv (): Wrong charset, conversion from 'ansi 'to 'utf-8 // IGNORE' is not allowed in D: \ xampp \ htdocs \ function \ cURL \ curl5.php on line 34 HTTP/1.1 200 OK Date: Mon, 03 Feb 2014 12:00:13 GMT Server: ATS/3.2.4 X-Powered-: PHP/5.3.9 Vary: Accept-Encoding Content-Type: text/html Age: 0 Transfer-Encoding: chunked Proxy-Connection: keep-alive: 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: # ebeb }. 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; position: 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; font-size: 12px; line-height: 1.2em; padding: 2px; width: auto ;} -29 [yellow] ����> ���� �� | ������������������������������������ �������������������������������������� �������������������������������������� ������������������������������������������ ���� �������������������������������������� �������������������������������� VS. -- -- p.m. -- ������������018 ���������������������������� VS ������ ��-29 �� � 001 �� 1. 29. VS �� --million n.-30 0:29 �� � 005 �� � �� VS. ˳ �� -30 0:44 ����������006 ���������������� VS ���� alibaba Cloud-��-30 0:44 �� ���� �� 010 �� VS �� ���� ��: ����, ������������011 ������������������������ VS ���� �� ���� 012 ��-30 �� �� Delta ��: ����, ������������013 ����������������������-01-30 07:59 �� ��������014 �������������������������� VS �� ������1-�� ������������001 ������������������������ VS ���� ����-31 �� 002 �� � �� VS �� ��-31 �� � �� 003 �� 2014-01-31- 31. ���������������������������������� �� matmatmatmatmatmatmat( '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 is as follows:

Output: (garbled !)

Notice: iconv (): Wrong charset, conversion from 'ansi 'to 'utf-8 // IGNORE' is not allowed in D: \ xampp \ htdocs \ function \ cURL \ curl5.php on line 34 HTTP/1.1 200 OK Date: Mon, 03 Feb 2014 12:00:13 GMT Server: ATS/3.2.4 X-Powered-: PHP/5.3.9 Vary: Accept-Encoding Content-Type: text/html Age: 0 Transfer-Encoding: chunked Proxy-Connection: keep-alive: 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: # ebeb }. 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; position: 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; font-size: 12px; line-height: 1.2em; padding: 2px; width: auto ;} -29 [yellow] ����> ���� �� | ������������������������������������ �������������������������������������� �������������������������������������� ������������������������������������������ ���� �������������������������������������� �������������������������������� VS. -- -- p.m. -- ������������018 ���������������������������� VS ������ ��-29 �� � 001 �� 1. 29. VS �� --million n.-30 0:29 �� � 005 �� � �� VS. ˳ �� -30 0:44 ����������006 ���������������� VS ���� alibaba Cloud-��-30 0:44 �� ���� �� 010 �� VS �� ���� ��: ����, ������������011 ������������������������ VS ���� �� ���� 012 ��-30 �� �� Delta ��: ����, ������������013 ����������������������-01-30 07:59 �� ��������014 �������������������������� VS �� ������1-�� ������������001 ������������������������ VS ���� ����-31 �� 002 �� � �� VS �� ��-31 �� � �� 003 �� 2014-01-31- 31. ���������������������������������� �� matmatmatmatmatmatmat( '19 ');

$file = iconv("gbk", "UTF-8//IGNORE", $file);
In this case, 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.