escape, encodeURI or encodeURIComponent?

M

Max

I have to encode (and decode) a URI in US-ASCII. What is the correct
encoder (and decoder) between escape(), encodeURI() and
encodeURIComponent()?

Max
 
T

Thomas 'PointedEars' Lahn

Max said:
I have to encode (and decode) a URI in US-ASCII. What is the correct
encoder (and decoder) between escape(), encodeURI() and
encodeURIComponent()?

The one that works in the respective execution environment, in the order
encodeURI(), escape(), and decodeURI(), unescape(). Because the former is
standardized in each case, the latter is not.

encodeURIComponent/decodeURIComponent (standardized) is, as the name says,
designed for URI components such as query part values.

See also esc() in http://PointedEars.de/scripts/string.js


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,139
Latest member
JamaalCald
Top