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)