4
如何把 utf8 汉字转 16 进制格式
source link: https://www.v2ex.com/t/811595
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
echo Utf8ToHex("5g");
function Utf8ToHex($str){
$str = rawurlencode($str);
$arr = explode('%',$str);
$Hex = implode('',$arr);
return $Hex;
}
我这个函数如果是汉字的情况它就是正确,如果是数字+英文,他就不行了。
比如输入5g
得到 16 进制是35 67
;
输入123456
得到 16 进制是31 32 33 34 35 36
;
网上找了几个 php 语言方法都不太好使
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK