Usage example of character encoding conversion function in php, php example _ PHP Tutorial

Source: Internet
Author: User
Tags php example
The usage example of the character encoding conversion function in php, and the php example. The usage example of the character encoding conversion function in php. the example in this article describes the usage of the character encoding conversion function in php. The specific implementation method is as follows: examples of character encoding conversion functions in php, and examples of php

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:

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

The code is as follows:

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

Examples in this article describe the usage of character encoding conversion functions in php and share them with you for your reference. The specific implementation method is as follows :...

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.