Example of character encoding conversion function usage in PHP, php example _php tutorial

Source: Internet
Author: User
Tags php example

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: ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.