What is the difference between the JavaScript functions decodeURIComponent and decodeURI?
What is the difference between the JavaScript functions decodeURIComponent and decodeURI ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To explain the difference between these two let me explain the difference between
encodeURIandencodeURIComponent.The main difference is that:
encodeURIfunction is intended for use on the full URI.encodeURIComponentfunction is intended to be used on .. well .. URI components that isany part that lies between separators (; / ? : @ & = + $ , #).
So, in
encodeURIComponentthese separators are encoded also because they are regarded as text and not special characters.Now back to the difference between the decode functions, each function decodes strings generated by its corresponding encode counterpart taking care of the semantics of the special characters and their handling.