/** * @description: 十六进制转字符串 * @param string $hex * @param string $mb_convert_encoding 转换后编码类型,默认转换成UTF-8 * @return string */ public function hexDecode($hex,$mb_convert_encoding='utf-8') { // 十六进制值转换为 ASCII 字符 $bin = hex2bin($hex); // 获取字符串编码 $encode = mb_detect_encoding($bin, array("ASCII",'UTF-8',"GB2312","GBK",'BIG5')); return mb_convert_encoding($bin, $mb_convert_encoding, $encode); }