Utf-8 how to turn into gb2312

Source: Internet
Author: User
CNT is a UTF-8 encoded page that passes over the address of the parameter,
Convert with Iconv and mb_convert_encoding
$cnt =iconv ("Utf-8", "Gb2312//ignore", $_get[' cnt]);

$cnt =mb_convert_encoding ($_get[' cnt '], "gb2312", "utf-8");


But Var_dump ($cnt) display of Chinese characters have become a box, ask how to convert?


Reply to discussion (solution)

What format is your file encoded in?
If it's gb2312,
Plus: Header ("content-type:text/html;charset=gb2312");
Then Var_dump ()

I added one to the head.


The same is true for the display or the box

$cnt =iconv ("Utf-8", "Gb2312//ignore", $_get[' cnt]);

$cnt =mb_convert_encoding ($_get[' cnt '], "gb2312", "utf-8");

Are the squares shown in both of these ways?
Your file code is also gb2312.

I am a novice, you say the file encoding is not this charset=gb2312? That's gb2312.

Save file as ANSI format

First, determine what's coming in.
echo base64_encode ($_get[' cnt ');
Post the results to help you analyze

Output the original variable look to see if there is a problem.

I am a novice, you say the file encoding is not this charset=gb2312? That's gb2312.

Oh, not this, CharSet just declares the code, I say the actual file encoding. Many Ides or editors can see the encoding of the file. For example, notepad++

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