Encoding:StringByAddingPercentEscapesUsingEncoding:
Returns a representation of the specified er using a given encoding to determine the percent escapes necessary to convert the specified ER into a legal URL string.-(NSString *)
Extracted from: http://hi.baidu.com/collect_zero/blog/item/a17948f716930123730eec7a.html
When URL is used for parameter transfer, some parameters or URL addresses with Chinese names are often passed, and conversion errors may occur during backend
Xu zening's PHP version of the escape/Unescape Function
CopyCodeThe Code is as follows: function escape ($ Str ){
Preg_match_all ("/[\ X80-\ xFF]. | [\ x01-\ x7f] +/", $ STR, $ R );
$ AR = $ R [0];
Foreach ($ Ar as $ k => $ v ){
If (ord ($ V [0]
As we all know, when searching for Chinese Characters in "Baidu.com", for example, "Old Three" Get the URL string: http://www.baidu.com/s? WD = % C0 % CF % C8 % FD & CL = 3, which is clearly encoded. What's going on?
Because some symbols cannot be
IOS uses CFURLCreateStringByAddingPercentEscapes for URL EncodingZookeeper
When the iOS program accesses HTTP resources, the URL must be UTF-8 encoded. I have always liked to use the stringByAddingPercentEscapesUsingEncoding method of NSString for
Escape () method:
The specified string is encoded using the ISO Latin character set. All space characters, punctuation marks, special characters, and other non-ASCII characters will be converted into character encoding in % xx format (xx equals to
1. Add the encoding method of the entire website to the web. config file. In this way, the parameters are transmitted in gb2312 Chinese encoding mode. The default value is UTF-8.2. the parameter is first encoded during transmission, first encoded
In ie, we often see the words "% CC % EC % CF % C2h" in the url bar, which are encoded strings transmitted in the URL, generally, Chinese characters are split into "% CC % EC". In fact, this conversion rule is simple, that is, to convert Byte
Example:
AAA. aspx? Tag =. Net % BC % Ca % F5AAA. aspx? Tag =. Net % E6 % 8A % 80% E6 % 9C % af
It seems to be different, in fact they are on the ". NET Technology" urlencode, but one is gb2312 encoding, one is the Utf-8 code.The following code
For example, when a user enters a keyword on the page, the submitted URL is: www.xxx.com/search.aspx? Q = Chinese
After you press enter in the address bar, ie, opera, and chrome will be displayed normally.
Firefox has garbled characters because
For example, the URL transmitted by Asp.net in get mode is: "webpage. asp? STR = "+ httputility. urlencode (STR)
The decoding method is httputility. urldecode (request. querystring ["str"]. tostring (). Trim ())
The ASP get method is transmitted
Understand urlencode:Urlencode: a pointer to the Chinese characters in the URL of a Web page. The most common method is to enter Chinese Characters in search engines such as Baidu and Google, generate a webpage URL that has passed the encode.
The get mode parameter is transferred as part of the URL. And for URLs are normative, Chinese characters beyond the scope of the specification.The Post method does not need to be encoded incorrectly. The code that complies with the server
JS URL EncodingEscape () Method:Encodes the specified string using the ISO Latin character set. All space characters, punctuation marks, special characters, and other non-ASCII characters are converted to the character encoding in the%xx format (XX
These days with Ajax do not refresh the page, check the relevant data: JS encoding the text involves 3 functions:
Escape,encodeuri,encodeuricomponent, corresponding 3 decoding functions: Unescape,decodeuri,decodeuricomponent
Escape () Method:
The
Solution: Use JS to the URL of the Chinese characters to escape code.
Copy Code code as follows:
So click on the effect of the link after:
Reference: http://127.0.0.1/shop/product_list.php?p_sort=PHP%u5F00%u53D1%u8D44%u6E90
DocumentWhen url is used for parameter transfer, some parameters or URL addresses with Chinese names are often passed, and conversion errors may occur during backend processing. In some transfer pages, GB2312 is used, and UTF8 is used on the
There are two ways of doing this:One, using the NSString method:nsstring* string2 = [string1 stringbyaddingpercentescapesusingencoding:nsutf8stringencoding];nsstring* string1 = [string2
In the previous article: [iOS] in WebApp How to use JS to call iOS functions, mentioned how to use JS by modifying the URL to invoke iOS intrinsic functions.There will be a problem, that is, coding problems, such as through the URL to call the
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.