9

colon is a character which can be encoded to '%3A' as per many sites and when I try to encode using URIencode it is not working

for example if I try to encode like URIencode(':'); then nothing happens. colon is returned. Why is this?? can someone help me out here.

Thanks in advance.

Jay Mayu
  • 17,023
  • 32
  • 114
  • 148
  • 2
    Take a look @ [What is the difference between decodeURIComponent and decodeURI?](http://stackoverflow.com/questions/747641/what-is-the-difference-between-decodeuricomponent-and-decodeuri) – Alex K. Feb 14 '13 at 10:27

1 Answers1

19

The encodeURI() encodes special characters, except:

, / ? : @ & = + $ #

You should use this instead encodeURIComponent(':');

This function encodes special characters. In addition, it encodes the characters skipped by encodeURI()

Salman
  • 9,299
  • 6
  • 40
  • 73