+ -
当前位置:首页 → 问答吧 → 关于utf-8 代码转换问题 求解

关于utf-8 代码转换问题 求解

时间:2011-01-18

来源:互联网

本帖最后由 buypro9 于 2011-01-18 14:53 编辑

通过一下在线工具http://tool.chinaz.com/Tools/UTF-8.aspx



我得到如下字符串(输入的是 "中文" 两个字)
1.----字符串1---------------------
下载 (4.01 KB)
2011-01-18 14:45
  由于该编码的字符串会被系统过滤掉,只能贴图片说明



我想问一下这是否就是utf-8格式的? 怎么和以下字符串2格式的utf-8有很大区别????
2.----字符串2---------------------
%E6%88%91%e4%bb%ac



那么如何用perl 将gb2312转成字符字符串1的格式?????


我用以下代码测试了以下结果网页上返回的结果看起来和以上格式都不同。如何能得到字符串1那样格式的字符串?

<meta http-equiv="content-type" content="text/html;charset=gb2312"><form method="post" action="utf8.cgi">
<p>word: <input name="word" type="text">  
<input type="submit" name="Submit" value=" 查询 ">
</form>


utf8.cgi-------------------

#!/usr/bin/perl -w
use CGI;
use Encode;
$query = new CGI;

$secretword = $query->param('word');
$remotehost = $query->remote_host();

$utf8 =encode("utf8",decode("gb2312",$secretword));

print $query->header(       -charset=>'gb2312'                                    );  


print "<p>The secret word is <b>$secretword</b> <br>and your IP is <b>$remotehost</b>.</p><br>";

print "utf编码 =$utf8<br>";

作者: buypro9   发布时间: 2011-01-18

我发现字符串1的格式的字符串  不管你怎么设定网页的charset,比如你就是强制设定为big5 网页也能正确显示出该文字这两字  

有谁能告诉我这是什么格式的字符编码吗?

作者: buypro9   发布时间: 2011-01-18