Source http://www.cnblogs.com/henw/archive/2011/11/08/2240779.html
JS encoding, decoding. Asp.net (C #) corresponding decoding, encoding
Escape unencoded characters are 69: *, +,-,.,/, @, _, 0-9, A-Z, A-Z
Encodeuri is not encoded with 82 characters :!, #, $, &, ', (,), *, +,-,.,/,:,;, = ,?, @,_,~, 0-9, A-Z, A-Z
Encodeuricomponent has 71 unencoded characters :!, ',(,),*,-,.,_,~, 0-9, A-Z, A-Z
1.
JS:Escape:
- You can use escape when JS uses data.
- For example, search for the history record in the bucket.
- When Unicode values other than 0-255 are encoded, the % u *** format is output. In other cases, escape, encodeuri, and encodeuricomponent are encoded with the same result.
Decoding: Unescape
C #:
Httputility. urlencode
Httputility. urldecode
2.
JS:Encodeuri:
- Encodeuri can be used for URL redirection.
- Example: location. href = encodeuri ("http://cang.baidu.com/do/s? WORD = Baidu & Ct = 21 ");
Decode Using decodeuri ();
C #:Decodeuricomponent
3.
JS:Encodeuricomponent:
- You must use encodeuricomponent when passing parameters so that the combined URL will not be truncated by special characters such.
- Example: <script language = "JavaScript"> document. Write ('<a href = "http://passport.baidu.com /? Logout & Aid = 7 & U = '+ encodeuricomponent ("http://cang.baidu.com/bruce42") +' "> exit </a & gt; '); </SCRIPT>
Decode Using decodeuricomponent ()
C #:
[Httpcontext. Current.] server. urldecode
[Httpcontext. Current.] server. urlencode
Escape unencoded characters are 69: *, +,-,.,/, @, _, 0-9, A-Z, A-Z
Encodeuri is not encoded with 82 characters :!, #, $, &, ', (,), *, +,-,.,/,:,;, = ,?, @,_,~, 0-9, A-Z, A-Z
Encodeuricomponent has 71 unencoded characters :!, ',(,),*,-,.,_,~, 0-9, A-Z, A-Z
1.
JS:Escape:
- You can use escape when JS uses data.
- For example, search for the history record in the bucket.
- When Unicode values other than 0-255 are encoded, the % u *** format is output. In other cases, escape, encodeuri, and encodeuricomponent are encoded with the same result.
Decoding: Unescape
C #:
Httputility. urlencode
Httputility. urldecode
2.
JS:Encodeuri:
- Encodeuri can be used for URL redirection.
- Example: location. href = encodeuri ("http://cang.baidu.com/do/s? WORD = Baidu & Ct = 21 ");
Decode Using decodeuri ();
C #:Decodeuricomponent
3.
JS:Encodeuricomponent:
- You must use encodeuricomponent when passing parameters so that the combined URL will not be truncated by special characters such.
- Example: <script language = "JavaScript"> document. Write ('<a href = "http://passport.baidu.com /? Logout & Aid = 7 & U = '+ encodeuricomponent ("http://cang.baidu.com/bruce42") +' "> exit </a & gt; '); </SCRIPT>
Decode Using decodeuricomponent ()
C #:
[Httpcontext. Current.] server. urldecode
[Httpcontext. Current.] server. urlencode