Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to detect UTF encoding using PHP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 578
    Comment on it

    Hello Readers! if you want to find out the type of file encoding using php then the code below will help you:-

      //check string strict for encoding out of list of supported encodings
        $enc = mb_detect_encoding($str, mb_list_encodings(), true);
    
        if ($enc===false){
            //could not detect encoding
        }
        else if ($enc!=="UTF-8"){
            $str = mb_convert_encoding($str, "UTF-8", $enc);
        }
        else {
    
    echo "UTF encoding is detected"      
    
        }
    

    In the code above if encoding is not detect as UTF then function mb_convert_encoding() will convert it into UTF

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: