文章提供這款mb_detect_encoding函數是一款可以檢測你使用的字符串是什么編碼,然后返回字符串編碼字符,下面是一個簡單應用實例.
- function asciitog($brand)
- {
- $cha=mb_detect_encoding($brand);
- if($cha=='utf-8')
- {
- $brand2 = iconv($cha,"gb2312",$brand);
- }
- $cha2=mb_detect_encoding($brand2);
- if($cha2!='ascii'){
- $brand=$brand2;
- }
- return $brand; //開源代碼Vevb.com
- }
mb_detect_encoding
語法:string mb_detect_encoding ( string $str [, mixed $encoding_list = mb_detect_order() [, bool $strict = false ]] )
說明:mb_detect_encoding 用來檢測字符串所使用編碼,并返回相對應編碼字符串.
|
新聞熱點
疑難解答