傳值涉及到中文字符串時,字符編碼的問題

 

 

經過POST或者GET進行傳值時,若是涉及到中文,應該使用相應的函數,編碼URL字符串。函數

  其中PHP對應的函數爲:urlencode (),js對應的函數爲:encodeURI()。編碼

  收到值後,在作對應的解碼。url

 

 

字符編碼相關的函數:spa

  mb_convert_encoding() — 轉換字符的編碼code

/* 將 EUC-JP 轉換成 UTF-7 */
$str = mb_convert_encoding($str, "UTF-7", "EUC-JP");

  mb_detect_encoding — 檢測字符的編碼blog

相關文章
相關標籤/搜索