mysql查询数据库中16进制中文内容

function unicode_encode($str, $encoding = 'GBK', $prefix = '&#', $postfix = ';') {
$str = iconv($encoding, 'UCS-2', $str);
$arrstr = str_split($str, 2);
$unistr = '';
for($i = 0, $len = count($arrstr); $i < $len; $i++) {
$dec = bin2hex($arrstr[$i]);
$decarr=str_split($dec);
$dec=$decarr[2].$decarr[3].$decarr[0].$decarr[1];
$unistr .= $prefix . $dec . $postfix;
}
return $unistr;
}

$keywords_unistr = unicode_encode($_GPC["keywords"],'UTF-8','u','\\\\');
$condition.=" and content like '%".$keywords_unistr."%' ";
原文地址:https://www.cnblogs.com/yangchong/p/14991964.html