-
-
function unicode_encode($str, $encoding='gbk', $prefix='', $postfix=';'){
- $str = iconv($encoding, 'ucs-2', $str);
- $arrstr = str_split($str, 2);
- $unistr = '';
- for($i=0, $len=count($arrstr); $i {
- $dec = hexdec(bin2hex($arrstr[$i]));
- $unistr .= $prefix.$dec.$postfix;
- }
- return $unistr;
- } // bbs.it-home.org
- $str = '哈哈';
- $unistr = unicode_encode($str);
- echo $unistr.'
';
- ?>
复制代码
|