UTF8转unicode

/**
* UTF8转unicode
* @param unknown_type $c
*/
function utf8_unicode($c) {
switch (strlen ( $c )) {
case 1 :
return ord($c);
case 2 :
$n = (ord ( $c [0] ) & 0x3f) << 6;
$n += ord ( $c [1] ) & 0x3f;
break;
case 3 :
$n = (ord ( $c [0] ) & 0x1f) << 12;
$n += (ord ( $c [1] ) & 0x3f) << 6;
$n += ord ( $c [2] ) & 0x3f;
break;
case 4 :
$n = (ord ( $c [0] ) & 0x0f) << 18;
$n += (ord ( $c [1] ) & 0x3f) << 12;
$n += (ord ( $c [2] ) & 0x3f) << 6;
$n += ord ( $c [3] ) & 0x3f;
break;
}

return $n;
}

你可能感兴趣的:(unicode)