zoukankan      html  css  js  c++  java
  • utf8.php

    <?php 
    /**
    * 
    */
    class Utf8
    {
        
        function __construct()
        {
            global $CFG;
            if(
                preg_match('/./u', '') === 1
                AND function_exists('iconv')
                AND ini_get('mbstring.func_overload') != 1
                )
            {
                define('UTF8_ENABLED', TRUE);
    
                if(extension_loaded('mbstring'))
                {
                    define('MB_ENABLED', TRUE);
                    mb_internal_encoding('UTF-8');
                }
            }
        }
    
        function clean_string($str)
        {
            $str = @iconv('UTF-8', 'UTF-8//IGNOE', $str);
            return $str;
        }
    
        function convert_to_utf8($str, $encoding)
        {
            if(function_exists('iconv'))
            {
                $str = @iconv($encoding, 'UTF-8', $str);
            }
            elseif(function_exists('mb_convert_encoding'))
            {
                $str = @mb_convert_encoding($str, 'UTF-8', $encoding);
            }
            else
            {
                return FALSE;
            }
    
            return $str;
        }
    
        function _is_ascii($str)
        {
            return (preg_match('/[^x00-x7F]/S', $str)==0);
        }
    }
  • 相关阅读:
    java第一次作业
    第十一次作业
    第十次作业
    第九次作业
    第八次作业
    第七次作业
    第六次作业
    第五次作业
    实验四,实验五
    Java_实验二
  • 原文地址:https://www.cnblogs.com/echoshao/p/6511182.html
Copyright © 2011-2022 走看看