PHP

php中的字符编码转换函数的用法

时间:2024-07-09 10:08:20 PHP 我要投稿
  • 相关推荐

php中的字符编码转换函数的用法

  一般来说,在网页程序中,尤其是涉及到数据库的读出过程中,往往最恼火的就是字符编码的问题,php4.0.6以上的版本提供了mb_convert_encoding 可以方便的转换编码。

  具体如下:

  复制代码 代码如下:<?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的字符串转为utf-8的,可以用如下方法:

  复制代码 代码如下:$str=mb_convert_encoding($str,"UTF-8","GB2312")

【php中的字符编码转换函数的用法】相关文章:

Excel中if函数使用的方法06-16

excel中sumif函数使用方法03-23

Excel中COUNTIF函数的使用方法01-23

在PHP7中不要做的10件事09-06

Excel中公式与函数的应用教案设计参考06-14

php实习心得12-01

php实习报告11-07

excel函数07-30

php工作总结11-11

php是什么格式?01-14