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.
Colon IS an invalid character in URL unless it is used for its purpose (for eg http://). "...Only alphanumerics [0-9a-zA-Z], the special characters "$-_. +! *'()," [not including the quotes - ed], and reserved characters used for their reserved purposes may be used unencoded within a URL."
It is completely fine to use a colon : in a URL path.
URL encoding converts characters into a format that can be transmitted over the Internet. - w3Schools. So, "/" is actually a seperator, but "%2f" becomes an ordinary character that simply represents "/" character in element of your url.
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()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With