zoukankan      html  css  js  c++  java
  • php识别中文编码并自动转换为UTF-8

    php自动识别编码,若里面有中文的话,将其转换为UTF-8就最好了,因为中文在Gbk编辑情况情况下,有可能会乱码,这个和客户端和服务端编码都有关系,为了避免乱码,我们可以使用下面的函数将其自动转换为UTF8国际标准编码:

    <?php
    function characet($data){
      if( !empty($data) ){
        $fileType = mb_detect_encoding($data , array('UTF-8','GBK','LATIN1','BIG5')) ;
        if( $fileType != 'UTF-8'){
          $data = mb_convert_encoding($data ,'utf-8' , $fileType);
        }
      }
      return $data;
    }
    ?>
  • 相关阅读:
    emacs command
    emacs format
    attach
    虚拟ip
    emacs redo
    mariadb
    unsafe
    select, poll, epoll
    03基于python玩转人工智能最火框架之TensorFlow介绍
    03SQL语句
  • 原文地址:https://www.cnblogs.com/qingsong/p/5931953.html
Copyright © 2011-2022 走看看