The question of question mark when the mb_convert_encoding function converts UTF-8 to gbk

Source: Internet
Author: User
When the mb_convert_encoding function UTF-8 is converted to gbk, the question mark of space is changed. how can this problem be solved? Only spaces are converted into question marks, and other Chinese characters are normal.


Reply to discussion (solution)

This is related to your editor. spaces are not standard spaces.
Can you
Echo base64_encode (your UTF-8 string ');
Posting result 1

I suspect that it is not a common space.

This is related to your editor. spaces are not standard spaces.
Can you
Echo base64_encode (your UTF-8 string ');
Posting result 1
This article says that this space is special, 0xC2 0xA0.
Http://hi.baidu.com/lilong2114311/item/6d0b20c87ede71c8984aa097

But I try to convert

$in = 'UTF-8';$out = 'GBK';$str = str_replace("0xC2 0xA0", ' ', $str);//$str = mb_convert_encoding($str, $out, $in); 


It has no effect. please advise

This is related to your editor. spaces are not standard spaces.
Can you
Echo base64_encode (your UTF-8 string ');
Posting result 1

The complete code is as follows:

 

This is related to your editor. spaces are not standard spaces.
Can you
Echo base64_encode (your UTF-8 string ');
Posting result 1

Search for "The fourth generation Fire in Muye ninja village, the country of fire" on the page. There are four question marks in front.

Check the source code and check that the Space is not normal (0x20), but 0xA0: No-Break Space (that is, nbsp)

You can't blame others if you're wrong.
$ Str = str_replace ("0xC2 0xA0", '', $ str );
Should be
$ Str = str_replace ("\ xC2 \ xA0", '', $ str );

In addition, the source code has a bom header.

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.