PHP about UTF-8 Chinese garbled solution

Source: Internet
Author: User
PHP about UTF-8 Chinese garbled solution 1. Use a form for submission, post, or get. In this way, if you use the get method when submitting the word "person", you will find that. The "person" cannot be found on the url in the ie address bar, and "% 4e % ba" is displayed, because when the ie form is submitted, it is automatically executed. Urlencode encoding, and when receiving the variable in the search page, php automatically give it to dec PHP about UTF-8 Chinese garbled solution

1. Use a form for submission, post, or get.
In this way, if you use the get method when submitting the word "person", you will find that. The "person" cannot be found on the url in the ie address bar, and "% 4e % ba" is displayed, because when the ie form is submitted, it is automatically executed. Urlencode encoding. when a variable is received on the search page, php automatically sends it to decode. So what you get is the UTF-8 "person. There is no problem. of course, the premise is that the page where your form is located is UTF-8 encoded.

?

2. The text link is submitted. The UTF-8 encoded page contains a text link, which is like xxxx. when you click submit, you will see that in the address bar of ie, you can see the "man", which is output after you receive it on the page. it turns into "bang". The problem arises. after submitting the UTF-8 page, the output page is also UTF-8 encoded, but it is an error. Note that this is not a problem with your environment settings. many articles on the Internet say that php. the ult_charset in ini can be opened and changed to UTF-8. this is an inaccurate statement. continue with our problem. this time, we will not output this word, encode it with urlencode and output the encoding, the result is changed to "% 4e % ba", with a high position missing. As a result, there is no higher level here, so nothing can be done on this page. Here is the problem with ie. UTF-8 encoding occupies three bytes for each Chinese character. when you submit a text link, if you write a Chinese character directly, this Chinese character is indeed UTF-8 encoded at the time of submission. However, due to the problem of html parsing by ie, he cut off the odd Chinese characters or the odd-number full-angle characters, processing in two bytes. In this way, the problem arises. Solution: write the keywords you submitted into an even number, so that these problems will not occur again. if there are only an odd number of keywords, urlencode will be used for the submission, or add a space in the front or back of the keyword to get the complete string on the receiving page.

?

3.In the ie address bar, you can manually write Chinese characters to open a page. this method is usually seen in paging queries. users with basic web page knowledge will query a keyword to save trouble, directly modify the url address to query another keyword. At this time, the Chinese character entered in the address bar is gb2312, instead of automatically converting the UTF-8 page. if you are interested, try urlencode. After you receive the keyword, you can use iconv to convert it to UTF-8 for query..

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.