/**
* 将字符用UTF-16编码
*
* @param
* @arrange (512.笔记) jb51.cc
**/
function encode($encode,$str,$isemail = false) {
$str = iconv($encode,"UTF-16BE",$str);
for ($i = 0; $i < strlen($str); $i++,$i++) {
$code = ord($str{$i}) * 256 + ord($str{$i + 1});
if ($code < 128 && !$isemail) {
$output .= chr($code);
} else if ($code != 65279) {
$output .= "&#".$code.";";
}
}
return $output;
}
/*** 来自编程之家 jb51.cc(jb51.cc) ***/