Home  >  Article  >  Backend Development  >  converse one star PHP mb_convert_encoding Gets the string encoding type implementation code

converse one star PHP mb_convert_encoding Gets the string encoding type implementation code

WBOY
WBOYOriginal
2016-07-29 08:39:50935browse

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
|
| xED[x80-x9F][x80-xBF] # excluding surrogates
| 3} # planes 4-15
| For research, it is recommended to read the "Multibyte String Functions" section of the PHP manual.

The above introduces the implementation code of converse one star PHP mb_convert_encoding to obtain the string encoding type, including the content of converse one star. I hope it will be helpful to friends who are interested in PHP tutorials.


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