%BD%CC%B3%CC+%CA%E9 是 UTF-8 编码吗?
可以给个代码看看吗?
谢谢~~~~~~
可以给个代码看看吗?
谢谢~~~~~~
解决方案 »
- 【急】delphi程序打包加密
- def文件如何导入到access数据库中
- 请教:本菜鸟用INDY做了个通讯小程序,但不知怎么发布,用WISE弄出的程序运行有界面,但登录没有反应。请高手指教!!
- 200 分请高手帮忙解决一下问题!!在线等候!!
- 我是新手,怎么样做登陆窗口
- 急!哪位兄弟帮我解决这个异常类啊?多谢!
- 100分求可多选的Combobox
- 开始学习Delphi 请推荐你们最喜欢帮助最大的Delphi书
- 请教如何在DELPHI中调用WINAPI函数?
- 哪里有关于用DelphiX开发DirectX游戏的文章或电子图书下载?
- 关于COM 接口实现问题请教
- 用WISE发布软件问题?再线等待!!!
function u2utf8($c)
{
for($i=0;$i<count($c);$i++)
$str="";
if ($c < 0x80) {
$str.=$c;
}
else if ($c < 0x800) {
$str.=(0xC0 │ $c>>6);
$str.=(0x80 │ $c & 0x3F);
}
else if ($c < 0x10000) {
$str.=(0xE0 │ $c>>12);
$str.=(0x80 │ $c>>6 & 0x3F);
$str.=(0x80 │ $c & 0x3F);
}
else if ($c < 0x200000) {
$str.=(0xF0 │ $c>>18);
$str.=(0x80 │ $c>>12 & 0x3F);
$str.=(0x80 │ $c>>6 & 0x3F);
$str.=(0x80 │ $c & 0x3F);
}
return $str;
}
====================================
这里完全是按照UTF-8编码的规则,通过判断字符属于不同的UNICODE编码段范围,进行不同的移位和位与操作,以转化为UTF-8编码。关于该规则可参考http://www.utf8.org/上的说明。这是修改前的GB转化为UTF-8编码的函数,其中调用了上面的u2utf8函数。
function gb2utf8($gb) /* Program writen by sadly www.phpx.com */
{
if(!trim($gb))
return $gb;
$filename="gb2312.txt";
$tmp=file($filename);
$codetable=array();
while(list($key,$value)=each($tmp))
$codetable[hexdec(substr($value,0,6))]=substr($value,7,6);
$utf8="";
while($gb)
{
if (ord(substr($gb,0,1))>127)
{
$this=substr($gb,0,2);
$gb=substr($gb,2,strlen($gb));
$utf8.=u2utf8(hexdec($codetable[hexdec(bin2hex($this))-0x8080]));
}
else
{
$gb=substr($gb,1,strlen($gb));
$utf8.=u2utf8(substr($gb,0,1));
}
}$ret="";
for($i=0;$i<strlen($utf8);$i+=3)
$ret.=chr(substr($utf8,$i,3));return $ret;
}
begin
ShowMessage(HTTPDecode('%BD%CC%B3%CC+%CA%E9'));
ShowMessage(HTTPEncode('教程 书'));
end;
@_@ 非常服你~~