What is the JavaScript equivalent of C# Server.URLEncode?
相关问题
- Angular RxJS mergeMap types
- Is there a limit to how many levels you can nest i
- Sorting 3 numbers without branching [closed]
- How to toggle on Order in ReactJS
- Graphics.DrawImage() - Throws out of memory except
No,
encodeURIComponent()
exactly.http://xkr.us/articles/javascript/encode-compare/#ref-js-msdn
There’s a wonderful article on xkr.us comparing javascript’s various escape functions. Do read it for details, but here’s a quick summery:
escape()
— don’t use: does not understand non-ASCII characters, and does not escape some important URI characters, such as+
.encodeURI()
— encodes an entire URI: as such, it leaves?
and&
unencoded.encodeURIComponent()
— encodes a component in a query string (this is usually the one you want, and appears to be the equivalent ofServer.URLEncode
).