Home > Backend Development > PHP Tutorial > 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
Release: 2016-07-29 08:39:50
Original
968 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
|
| 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.


Related labels:
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