/**
     * @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);
    }

 

posted on 2023-03-06 11:08  allen817  阅读(219)  评论(0编辑  收藏  举报