亂碼問題,請教

來源:互聯網
上載者:User
$city = $this->uri->segment(4);
//var_dump(json_decode($city,true));
//$city = iconv("utf-8","utf-8",$this->uri->segment(4));
$city = urldecode($this->uri->segment(4));
var_dump($city);
$city = iconv("ISO-8859-1","GBK",$city);
echo $city;
echo "
"."222";
print_r(iconv_get_encoding());


當前瀏覽器中頁面的編碼是gbk,用函數輸出 是ISO-8859-1。 原始什麼都不轉換輸出是%E5%8C%97%E4%BA%AC
瀏覽器換成unicode就顯示正常了

搞一陣了,先謝謝了


回複討論(解決方案)

用mb_convert_encoding??。

用mb_convert_encoding??。




不好使

搞定

header("content-Type: text/html; charset=utf-8");

還是這個好使

沒有指定網頁編碼。

$city = $this->uri->segment(4); 這種取值方法太笨, 再者這個城市的名稱不可以用ID號來表示麼

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.