Home  >  Article  >  Backend Development  >  Usage example of character encoding conversion function in php, php example_PHP tutorial

Usage example of character encoding conversion function in php, php example_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:16:31755browse

Usage example of character encoding conversion function in php, php example

The example in this article describes the usage of the character encoding conversion function in PHP and is shared with everyone for your reference. The specific implementation method is as follows:

Generally speaking, in web programs, especially when it comes to the process of reading out the database, the most annoying thing is often the problem of character encoding. PHP4.0.6 or above provides mb_convert_encoding to conveniently convert the encoding.

The details are as follows:

Copy code The code is as follows:
/* Convert internal character encoding to SJIS */
$str = mb_convert_encoding($str, "SJIS");

/* Convert EUC-JP to UTF-7 */
$str = mb_convert_encoding($str, "UTF-7", "EUC-JP");

/* Auto detect encoding from JIS, eucjp-win, sjis-win, then convert str to UCS-2LE */
$str = mb_convert_encoding($str, "UCS-2LE", "JIS, eucjp-win, sjis-win");

/* "auto" is expanded to "ASCII,JIS,UTF-8,EUC-JP,SJIS" */
$str = mb_convert_encoding($str, "EUC-JP", "auto");
?>

For example, if you want to convert a gb2312 string to utf-8, you can use the following method:

Copy code The code is as follows:
$str=mb_convert_encoding($str,"UTF-8","GB2312")

I hope this article will be helpful to everyone’s PHP programming design.

php encoding converted into Chinese characters

You are talking about URL encoding, right?

PHP actually has functions in this area:
So you only need to use the urldecode() function That's it.

Thank you!

php character encoding conversion Don’t know the original encoding

Open it with your browser and see what code it automatically recognizes

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/897009.htmlTechArticleUsage example of character encoding conversion function in php, php example This article describes the use of character encoding conversion function in php Usage, shared with everyone for your reference. The specific implementation method is as follows:...
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