字符串转换成UTF-8编码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
Php代码 function strToUtf8($vector) { $from_chr = mb_detect_encoding ( $vector, array ( 'UTF-8', 'ASCII', 'EUC-CN', 'CP936', 'BIG-5', 'GB2312', 'GBK' ) ); if ($from_chr != "UTF-8") { $vector = mb_convert_encoding ( $vector, 'UTF-8', array ( 'UTF-8', 'ASCII', 'EUC-CN', 'CP936', 'BIG-5', 'GB2312', 'GBK' ) ); } return $vector; } |