views:

139

answers:

2

Hi,

I wrote a custom xml parser and its locking up on special characters. So naturally I urlencoded them into my database.

I can't seem to find an equivalent to php's urldecode()

are there any extentions for jquery or javascript that can accomplish this?

A: 

i think you need decodeURI function

shabunc
Not entirely (see Kenny's answer).
Pekka
+5  A: 

You could use the decodeURIComponent function to convert the %xx into characters. However, to convert + into spaces you need to replace them in an extra step.

function urldecode(url) {
  return decodeURIComponent(url.replace(/\+/g, ' '));
}
KennyTM