program development

json gbk to utf8

After dedecms implemented click to load more functions, I was depressed for a long time when calling the article description and found that what was called was empty, and then […]

article directories

After dedecms implemented click to load more functions, I was depressed for a long time when calling the article description and found that what was called was empty. Later, I learned that if I used gbk's dedecms, I needed to do a conversion if I got the data. Here is the json conversion code

function ct2($s){ if (is_numeric($s)) { return intval($s); } else { return iconv ("GBK","UTF-8",$s); }/* Batch processing gbk-> utf-8 */function icon_to_utf8($s) { if (is_array($s)) { foreach($s as $key => $val) { $s[$key] = icon_to_utf8($val); } } else { $s = ct2 ($s); } return $s;}echo json_encode(icon_to_utf8 ('the data you need to convert '));