JS and c-sharp encoding and decoding
- 2020-03-30 00:41:18
- OfStack
Escape has 69 unencoded characters: *, +, -,., /, @, _, 0-9, a-z, a-z
EncodeURI does not encode 82 characters:! , #, $, &, ', (,), *, +,, -,. , =? @, _, ~, 0 minus 9, a minus z, a minus z
EncodeURIComponent does not encode 71 characters:! , ', (,), *, -,., _, ~, 0-9, a-z, a-z
1.
JS: escape:
Escape can be used when using data in js
For example, search the history records in the collection.
When encoding unicode values other than 0-255, the output %u*** format is output. Otherwise, the encoding results of escape, encodeURI and encodeURIComponent are the same.
The decoder USES: unescape
C # :
HttpUtility. UrlEncode
HttpUtility. UrlDecode
2.
JS: encodeURI:
EncodeURI can be used as a whole when url jumping
For example: the Location href = encodeURI (" http://cang.baidu.com/do/s? The word = baidu & ct = 21 ");
Decoder USES decodeURI();
C # : decodeURIComponent
3.
JS: encodeURIComponent:
EncodeURIComponent is used when passing parameters so that the combined url is not truncated by special characters such as #.
For example: < Script language = "javascript" > Document. Write (' < A href = "http://passport.baidu.com/? Logout&aid = 7 &
U = '+ encodeURIComponent (" http://cang.baidu.com/bruce42 ") +' "> Exit < / a > '); < / script>
Decoder using decodeURIComponent()
C # :
[HttpContext. Current.] Server. UrlDecode
[HttpContext. Current.] Server. UrlEncode