Php functions for obtaining the encoding format of strings

Source: Internet
Author: User
Php functions for obtaining the encoding format of strings

  1. $ Encode = mb_detect_encoding ($ string, array ("ASCII", 'utf-8', "gb2312'," GBK ", 'big5 ′));
  2. Echo $ encode;

So that we can know what encoding format it is.

In addition, if you want to transcode it, you can refer to the following code:

  1. If ($ encode = "UTF-8 ″){
  2. $ String = iconv ("UTF-8", "GBK", $ string );
  3. }

The PHP file or string encoding format involves a wide range of content. I will introduce it in detail later. Let's talk about this today. I hope it will help you. Articles you may be interested in: learning php string encoding conversion and determining whether php determines whether the string encoding is utf8 function example php determines the two methods of character encoding php automatically detects the content encoding and the conversion code automatically detects the encoding in the content and the conversion function php encoding conversion function (the automatic conversion character set supports array conversion) php function iconv

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.