Created
September 24, 2011 00:45
-
-
Save kkozmic/1238786 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
say I want to escape C# string: @"http://somesite.com/?arg=value&foo=bar" | |
HtmlEncode does: | |
http://somesite.com/?arg=value&foo=bar | |
JavaScript escape is: | |
http:\x2F\x2Fsomesite.com\x2F?arg=value\&foo=bar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
javascript
->c#
escape
->have no c# analogue?
encodeURI
->Uri.EscapeUriString
encodeURIComponent
->HttpUtility.UrlEncode
orUri.EscapeDataString
According to http://xkr.us/articles/javascript/encode-compare/
you should avoid use of escape() whenever possible. The best alternative is usually encodeURIComponent()
Also note that
HttpUtility.HtmlEncode
encodes html-entities&
->&
,>
->>
and other