Follow this Blog!

May 20, 2013

f Comment

JavaScript: How Do You Convert Non ASCII URL Encoded Characters Back to Its Original Form?

Amazon In JavaScript how do you convert a non-ascii URL encoded character back to its raw form? For example how do you convert %E5%88%A5 to ?

別 is a UTF8 based character whose URL encoded value, or percent encoded value, is %E5%88%A5.
Read on to see the solution.

The following JavaScript function would convert %E5%88%A5 to .

For some reason Chrome (version 26.0.1410.64 m) and Firefox (version 20.0) encodes percent sign, or %, when saving UTF8 strings (e.g. %25E5%2588%25A5) in cookies.

However when you get the cookie's value from Chrome you get the correct URL encoded strings (e.g. %E5%88%A5) again. In this case simply do the following.

Internet Explorer (version 9.0) stores the correct URL encoded strings (e.g. %E5%88%A5) in cookies from the get go.

If you have any questions let me know and I will do my best to help you!
Please leave a comment here!
One Minute Information - by Michael Wen
Find Michael on Google or Facebook
ADVERTISING WITH US - Direct your advertising requests to Michael