JS and C # encoding and decoding,
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