• 编码转换方法


    public static function get_utf8($array, $type = 'utf-8') {   

          if (! empty ( $array )) {  

                   if (is_array ( $array )) {  

                           foreach ( $array as $k => $v ) {    

                                    if (is_array($v)) {     

                                         $arr [$k] = self::get_utf8 ( $v, $type );    

                                   } else {     

                                         if ($type == 'utf-8') {      

                                               if(CHAR=='utf-8'){       

                                                       $arr [$k] = $v;//系统编码UTF8 需要返回UTF8编码,直接返回      

                                                              }    else{        $arr [$k] = iconv ( 'gb2312', 'utf-8', $v );//系统编码GB2312  需要返回UTF8编码,处理返回       }

         } else {      

                                  if(CHAR=='gb2312'){       

                                           $arr [$k] = iconv ( 'utf-8', $type, $v );//系统编码UTF8  需要返回GB2312编码,处理返回      

                                                  }       else{        $arr [$k] =$v;//系统编码GB2312 需要返回GB2312编码,直接返回      

                        }     

                   }    

               }   

         }  

    } else {   

           if ($type == 'utf-8') {   

                     if(CHAR=='utf-8'){     

                             $arr =$array;//系统编码UTF8 需要返回UTF8编码,直接返回    

                                 }     else{     

                                    $arr = iconv ( 'gb2312', 'utf-8', $array );//系统编码GB2312  需要返回UTF8编码,处理返回    

             }  

       } else {    

                     if(CHAR=='gb2312'){    

                                   $arr = iconv ( 'utf-8', $type, $array );//系统编码UTF8  需要返回GB2312编码,处理返回    

                     }     else{     

                                 $arr =$array;//系统编码GB2312 需要返回GB2312编码,直接返回    

             }   

         }  

      }

    }

      return $arr;

    }

  • 相关阅读:
    Pytest单元测试框架——Pytest+Allure+Jenkins的应用
    Postman+Newman+Git+Jenkins接口自动化测试
    Pytest单元测试框架——Pytest简介
    unittest单元测试框架
    Postman学习笔记(二)
    CukeTest+Puppeteer的Web自动化测试(二)
    Postman学习笔记(一)
    CukeTest+Puppeteer的Web自动化测试(一)
    Puppeteer笔记(八):Puppeteer执行自定义Javascript方法
    Puppeteer笔记(七):Puppeteer切换浏览器TAB页
  • 原文地址:https://www.cnblogs.com/xlz307/p/3425387.html
Copyright © 2020-2023  润新知