function singledectohex($dec)
{
$tmp=;
$dec=$dec%16;
if($decreturn $tmp.$dec;
$arr=array(a,b,c,d,e,f);
return $tmp.$arr[$dec-10];
}
function singlehextodec($hex)
{
$v=ord($hex);
if(47return $v-48;
if(96return $v-87;
}
function settohexstring($str)
{
if(!$str)return false;
$tmp=;
for($i=0;$i{
$ord=ord($str[$i]);
$tmp.=singledectohex(($ord-$ord%16)/16);
$tmp.=singledectohex($ord%16);
}
return $tmp;
}
function unsetfromhexstring($str)
{
if(!$str)return false;
$tmp=;
for($i=0;$i{
$tmp.=chr(singlehextodec(substr($str,$i,1))*16+singlehextodec(substr($str,$i+1,1)));
}
return $tmp;
}
?>
settohexstring(大家好)==settohexstring(大家好)?>
unsetfromhexstring(settohexstring(大家好))==unsetfromhexstring(settohexstring(大家好))?>
http://www.bkjia.com/phpjc/532175.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/532175.htmltecharticlefunction singledectohex($dec) { $tmp=; $dec=$dec%16; if($dec return $tmp.$dec; $arr=array(a,b,c,d,e,f); return $tmp.$arr[$dec-10]; } function singlehextodec($hex) { $...