robinhunan
注册会员

一般会员
UID 20392
精华
0
积分 180
帖子 150
金钱 180 喜悦币
威望 0
人脉 0
阅读权限 20
注册 2003-6-3
状态 离线
|
[推荐阅读] 如何用frame实现无闪刷新!!!
你的文件,提交的数据都是utf8的数据,假如说把你的代码的
header("Content-Type: text/html; charset=UTF-8"); 行改成
header("Content-Type: text/html; charset=GBK");
就不能用了。也就是说直接使用<?php echo ascii::encode('中国');?>
如果上面这段代码保存成GBK是得不到正确结果的。必须保存成utf-8
也就是说要想在一个页面里面显示多个国家的语言,还是需要知道原来的代码的,
这个方法,可行行更好。效率也要高一些。 http://www.coolcode.cn/?p=5
function encode2($encode, $str) {
$str = iconv($encode, "UTF-16", $str);
for ($i = 0; $i < strlen($str); $i++,$i++) {
$code = ord($str{$i}) * 256 + ord($str{$i + 1});
if ($code < 128 ) {
$output .= chr($code);
} else if ($code != 65279) {
$output .= "&#".$code.";";
}
}
return $output;
}
|
|