標題:
[SQL與PHP]
mb_convert_encoding - 遇到某些API的回傳值編碼不是自己要的? 來轉碼吧
[打印本頁]
作者:
gswdkimo
時間:
2011-3-6 20:39
標題:
mb_convert_encoding - 遇到某些API的回傳值編碼不是自己要的? 來轉碼吧
mb_convert_encoding這函式其實蠻好用的,他可以將指定字串進行編碼轉換,而且不限制是utf8->big5或是反過來,甚至GBK還有各種其他國家的編碼都可以轉換,但是使用前必須要先確定你的PHP的mbstring是開啟的
[attach]137[/attach]
↑↑Windows用戶可以到C:\Windows\php.ini檢查php_mbstring.dll是否有安裝好
修改 php.ini 中,將 extension=php_mbstring.dll 前面的分號去除
mb_convert_encoding格式
mb_convert_encoding(要編碼的字串,目標編碼格式,原本的編碼格式)
Ex.
把utf-8的字串轉換成big-5
$str='測試';
echo $str; //此時是UTF-8
$str=mb_convert_encoding($str,'big5','utf8');
echo $str; //此時是BIG-5
複製代碼
歡迎光臨 資訊家電班NO7 (http://imce07.freehostia.com/forums/)
Powered by Discuz! 7.2