Home > Backend Development > PHP Tutorial > PHP mb_convert_encoding Gets the string encoding type implementation code_PHP tutorial

PHP mb_convert_encoding Gets the string encoding type implementation code_PHP tutorial

WBOY
Release: 2016-07-21 15:47:19
Original
775 people have browsed it

Later, I found the is_utf8 function in the manual. In this way, combined with the iconv function, my problem was solved. This function is posted below:

Copy code The code is as follows:

function is_utf8($string) {
return preg_match('%^(?:
[x09x0Ax0Dx20-x7E] # ASCII
| [xC2-xDF][x80-xBF] # non-overlong 2-byte
| xE0[xA0-xBF ][x80-xBF] # excluding overlongs
| [xE1-xECxEExEF][x80-xBF]{2} # straight 3-byte
| xED[x80-x9F][x80-xBF] # excluding surrogates
| x80-x8F][x80-xBF]{2} # plane 16
)*$%xs', $string);
} // function is_utf8


if If you want to study in depth, it is recommended to read the "Multibyte String Functions" section of the PHP manual.


http://www.bkjia.com/PHPjc/319973.html

truehttp: //www.bkjia.com/PHPjc/319973.htmlTechArticleLater I found the is_utf8 function in the manual. In this way, combined with the iconv function, my problem was solved. This function is posted below: Copy code The code is as follows: function is_utf8($str...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template