Home  >  Article  >  Backend Development  >  Method (function) to parse php to obtain the encoding format of a string_PHP tutorial

Method (function) to parse php to obtain the encoding format of a string_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:04:23788browse

If you don’t know the encoding format of the string, you can check this character like this:
$encode = mb_detect_encoding($string, array("ASCII",'UTF-8′,"GB2312′," GBK",'BIG5′));
echo $encode;
This way you can know what encoding it is. You can also transcode it in subsequent operations:
if ($encode = = “UTF-8″){
$string = iconv("UTF-8″,"GBK",$string);
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327761.htmlTechArticleIf you don’t know the encoding format of the string, you can check this character like this: $encode = mb_detect_encoding( $string, array("ASCII",'UTF-8′,"GB2312′,"GBK",'BIG5′)); ec...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn