国产激情久久久久影院小草_国产91高跟丝袜_99精品视频99_三级真人片在线观看

php中的字符編碼轉(zhuǎn)換函數(shù)的用法

時(shí)間:2024-09-10 12:26:50 PHP 我要投稿
  • 相關(guān)推薦

php中的字符編碼轉(zhuǎn)換函數(shù)的用法

  一般來說,在網(wǎng)頁程序中,尤其是涉及到數(shù)據(jù)庫(kù)的讀出過程中,往往最惱火的就是字符編碼的問題,php4.0.6以上的版本提供了mb_convert_encoding 可以方便的轉(zhuǎn)換編碼。

  具體如下:

  復(fù)制代碼 代碼如下:<?php

  /* Convert internal character encoding to SJIS */

  $str = mb_convert_encoding($str, "SJIS");

  /* Convert EUC-JP to UTF-7 */

  $str = mb_convert_encoding($str, "UTF-7", "EUC-JP");

  /* Auto detect encoding from JIS, eucjp-win, sjis-win, then convert str to UCS-2LE */

  $str = mb_convert_encoding($str, "UCS-2LE", "JIS, eucjp-win, sjis-win");

  /* "auto" is expanded to "ASCII,JIS,UTF-8,EUC-JP,SJIS" */

  $str = mb_convert_encoding($str, "EUC-JP", "auto");

  ?>

  比如要把gb2312的字符串轉(zhuǎn)為utf-8的,可以用如下方法:

  復(fù)制代碼 代碼如下:$str=mb_convert_encoding($str,"UTF-8","GB2312")

【php中的字符編碼轉(zhuǎn)換函數(shù)的用法】相關(guān)文章:

php字符串處理函數(shù)大全08-21

簡(jiǎn)單介紹php構(gòu)造函數(shù)用法08-31

JavaScript中常見的字符串操作函數(shù)及用法07-24

關(guān)于php中的一個(gè)中文字符串截取函數(shù)07-15

PHP中函數(shù)的使用說明09-01

PHP中的排序函數(shù)區(qū)別分析08-23

PHP的壓縮函數(shù)06-21

php中dirname()和--FILE--常量的用法09-26

關(guān)于php去除字符串中空字符的常用方法09-14

淺析php函數(shù)的實(shí)例06-08