传值涉及到中文字符串时,字符编码的问题

通过POST或者GET进行传值时,如果涉及到中文,应该使用相应的函数,编码URL字符串。

  其中PHP对应的函数为:urlencode (),js对应的函数为:encodeURI()。

  收到值后,在做对应的解码。

字符编码相关的函数:

  mb_convert_encoding() — 转换字符的编码

/* 将 EUC-JP 转换成 UTF-7 */
$str = mb_convert_encoding($str, "UTF-7", "EUC-JP");

  mb_detect_encoding — 检测字符的编码

原文地址:https://www.cnblogs.com/wangyuman26/p/8682189.html