Reputation: 143
I have string that is encoded in UTF16 and i want to decode it using JS, when i use simple decodeURI() function i get the desired result but in case when special characters are there in the string like á, ó, etc it do not decodes. On more analysis i came to know that these characters in the encoded string contains the ASCII value.
Say I have string "Acesse já, Encoded version : "Acesse%20j%E1". How can i get the string from the encode version using java script?
EDIT: The string is a part of URL
Upvotes: 0
Views: 2435
Reputation: 3238
Ok, your string seems to have been encoded using escape
, use unescape
to decode it!
unescape('Acesse%20j%E1'); // => 'Acesse já'
However, escape
and unescape
are deprecated, you’d better use encodeURI
or encodeURIComponent
here.
encodeURIComponent('Acesse já'); // => 'Acesse%20j%C3%A1'
decodeURIComponent('Acesse%20j%C3%A1'); // => 'Acesse já'
Upvotes: 3