Home > Web Front-end > JS Tutorial > JS and C# encoding and decoding_javascript skills

JS and C# encoding and decoding_javascript skills

WBOY
Release: 2016-05-16 17:11:05
Original
1112 people have browsed it

There are 69 characters that are not encoded by escape: *, ,-,.,/,@,_,0-9,a-z,A-Z

encodeURI has 82 non-encoded 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 using data in js
For example: history record in collection.
When encoding unicode values ​​other than 0-255, the %u**** format is output. In other cases, the encoding results of escape, encodeURI, and encodeURIComponent are the same.

Decode using: unescape

C#:

HttpUtility.UrlEncode
HttpUtility.UrlDecode

2.

JS: encodeURI:

You can use encodeURI as a whole when performing url jump
For example: Location.href=encodeURI("http://cang.baidu.com/do/s?word=Baidu&ct=21");

Decode using decodeURI();

C#: decodeURIComponent

3.

JS: encodeURIComponent:

You need to use encodeURIComponent when passing parameters, so that the combined url will not be truncated by special characters such as #.

For example:

Decode using decodeURIComponent()

C#:

[HttpContext.Current.]Server.UrlDecode

[HttpContext.Current.]Server.UrlEncode

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template