关于utf-8 代码转换问题 求解
时间:2011-01-18
来源:互联网
本帖最后由 buypro9 于 2011-01-18 14:53 编辑
通过一下在线工具http://tool.chinaz.com/Tools/UTF-8.aspx
我得到如下字符串(输入的是 "中文" 两个字)
1.----字符串1---------------------
由于该编码的字符串会被系统过滤掉,只能贴图片说明
我想问一下这是否就是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>";
通过一下在线工具http://tool.chinaz.com/Tools/UTF-8.aspx
我得到如下字符串(输入的是 "中文" 两个字)
1.----字符串1---------------------

我想问一下这是否就是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
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28