I have a web service that receives data from various clients. Some of them sends the data encoded using escape(), while the others instead use encodeURIComponent(). Is there
Thanks for @mika for great answer. Maybe just one improvement since unescape function is considered as deprecated:
declare function unescape(s: string): string;
decodeURItoString(str): string {
var resp = str;
try {
resp = decodeURI(str);
} catch (e) {
console.log('ERROR: Can not decodeURI string!');
if ( (unescape != null) && (unescape instanceof Function) ) {
resp = unescape(str);
}
}
return resp;
}