Php character encoding conversion function usage example, php example
This article describes the usage of character encoding conversion functions in php. The specific implementation method is as follows:
Generally, character encoding is the most annoying issue in Web applications, especially when it comes to reading data from databases. php4.0.6 or later versions provide mb_convert_encoding for easy conversion.
The details are as follows:
Copy codeThe Code is as follows: <? Php
/* Convert internal character encoding to SJIS */
$ Str = mb_convert_encoding ($ str, "SJIS ");
/* Converter 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 a gb2312 string to UTF-8, use the following method:
Copy codeCode: $ str = mb_convert_encoding ($ str, "UTF-8", "GB2312 ")
I hope this article will help you with PHP programming.
Php encoding into Chinese Characters
What do you mean by URL encoding?
PHP actually has the following functions:
<? Php // URL encoded echo urlencode ('windowsill butterfly '); // output % B4 % B0 % CC % A8 % BA % FB % B5 % FB // URL Decoding echo urldecode ('% B4 % B0 % CC % A8 % BA % FB % b5 % FB '); // output the window sill butterfly?> Therefore, you only need to use the urldecode () function.
Thank you!
Php character encoding conversion unknown original Encoding
You can open it in a browser to see what the code is automatically recognized by him.