zoukankan      html  css  js  c++  java
  • php 常用字符编码转换函数整理

    inconv()函数:

    范例:

    inconv('GB2312','UTF-8',$str);//将字符串的编码由gb2312转换为utf-8

    inconv_substr($str,1,1,'UTF-8');//按字符个数截取而非字节

    $code =inconv_get_encoding();//获取当前页面编码信息

    iconv_strlen($str,'UTF-8');//得到设定编码的字符串长度

    mb_convert_encoding()函数:

    范例:

    $str = mb_convert_encoding($str,'utf-8');//将字符串转化为utf-8格式

    $str = mb_convert_encoding($str,'utf-8','gb2312');//将字符串由gb2312转换为utf-8格式

    $str = mb_convert_encoding($str,'utf-8','gb2312,ASCII');自动将gb2312或者ASCII格式转换为utf-8

    $str = mb_convert_encoding($str,'utf-8','auto');//auto:ASCII,JIS,UTF-8,EUC-JP,SJIS

    mb_detect_encoding() 检测当前字符编码

    $encode = mb_detect_encoding($str,array('ASCII','UTF-8','GB2312','GBK','BIG5'));

    其他相关函数:

    utf8_encode utf8_decode

    urlencode urldecode

    json_encode json_decode

  • 相关阅读:
    关于c语言的左移运算
    如何修改mac的root密码
    LaTeX语法笔记
    texlive测试是否安装成功
    latex学习(四)tlmgr
    latex学习(三)
    latex学习(二)
    Latex学习(一)
    引导修复软件boot-repair
    MySQL远程连接和备份还原
  • 原文地址:https://www.cnblogs.com/longdidi/p/2946902.html
Copyright © 2011-2022 走看看