您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php的iconv编码转换问题!

2025/11/20 21:24:00发布14次查看
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如下:
输出如下:(乱码!)
notice: iconv(): wrong charset, conversion from `ansi' to `utf-8//ignore' is not allowed in d:\xampp\htdocs\function\function\curl\curl5.php on line 34http/1.1 200 ok date: mon, 03 feb 2014 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;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; } ����ʱ�䣺01-29 15:43 [ˢ��] �й������� >> ��ע���� �������� | ȫ������ �����׼������¹��׼����������׼��������ϻᱭ��������߱����籭Ԥѡ���ո������������������������������������׼�����ӣ������������ӣ�����ھ�����ӣ�����׼����� ע ����ҳ����ʾ����δ����������ϣ���鿴���������������ع̶�����ʤƽ���淨ҳ�桱�� �������� ȫ������ͷ ���±�� ���� ���� vs �ͷ� Ԥ�ƽ�ֹ����ʱ�� ������ѷ ����״̬ ��ע �ر���ʾ �������� ����002�¹��׼�����˹ͼ���� vs ����ľ���2014-01-30 02:59 �ѿ�������003�������������϶��ͷ����� vs �����ᄎ��2014-01-30 02:59 �ѿ�������008ӣ������������������ķ�ȴ� vs ����˹�س�2014-01-30 03:44 �ѿ�������009��������dz���˹ 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 �ѿ��� ע ����ҳ����ʾ����δ����������ϣ���鿴���������������ع̶�����ʤƽ���淨ҳ�桱�� match_counts('19');

回复内容: 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如下:
输出如下:(乱码!)
notice: iconv(): wrong charset, conversion from `ansi' to `utf-8//ignore' is not allowed in d:\xampp\htdocs\function\function\curl\curl5.php on line 34http/1.1 200 ok date: mon, 03 feb 2014 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;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; } ����ʱ�䣺01-29 15:43 [ˢ��] �й������� >> ��ע���� �������� | ȫ������ �����׼������¹��׼����������׼��������ϻᱭ��������߱����籭Ԥѡ���ո������������������������������������׼�����ӣ������������ӣ�����ھ�����ӣ�����׼����� ע ����ҳ����ʾ����δ����������ϣ���鿴���������������ع̶�����ʤƽ���淨ҳ�桱�� �������� ȫ������ͷ ���±�� ���� ���� vs �ͷ� Ԥ�ƽ�ֹ����ʱ�� ������ѷ ����״̬ ��ע �ر���ʾ �������� ����002�¹��׼�����˹ͼ���� vs ����ľ���2014-01-30 02:59 �ѿ�������003�������������϶��ͷ����� vs �����ᄎ��2014-01-30 02:59 �ѿ�������008ӣ������������������ķ�ȴ� vs ����˹�س�2014-01-30 03:44 �ѿ�������009��������dz���˹ 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 �ѿ��� ע ����ҳ����ʾ����δ����������ϣ���鿴���������������ع̶�����ʤƽ���淨ҳ�桱�� match_counts('19');

$file = iconv(gbk, utf-8//ignore, $file);
这样就ok了。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product