Example of character encoding conversion function usage in PHP, php example
In this paper, the use of the character encoding conversion function in PHP is described and shared for everyone's reference. The implementation method is as follows:
In general, in the Web program, especially when it comes to the reading process of the database, the most annoying is the problem of character encoding, php4.0.6 the version above provides mb_convert_encoding can be easily converted code.
Specific as follows:
Copy the Code code as follows: <?php
/* 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, to convert the gb2312 string to Utf-8, you can use the following method:
Copy the code as follows: $str =mb_convert_encoding ($str, "UTF-8", "GB2312")
I hope this article is helpful to everyone's PHP programming.
PHP code converted into Chinese characters
Are you talking about URL coding?
PHP actually has this kind of function:
So you just need to use the UrlDecode () function.
Thank you!
PHP character encoding conversion does not know the original encoding
You open it with a browser and see what he automatically recognizes.
http://www.bkjia.com/PHPjc/897009.html www.bkjia.com true http://www.bkjia.com/PHPjc/897009.html techarticle example of character encoding conversion function usage in PHP, php example This article describes the use of the character encoding conversion function in PHP, to share with you for your reference. The concrete implementation method is as follows: ...