MDN is suggesting to use encodeURI and encodeURIComponent instead of depreciated escape method.But both of these methods are not giving same output what escape used to give.
We have a scenario where JavaScript is receiving byte array from WCF web service which was encoded using UTF8. The data has special chars as well which produces 3 bytes / each character when we convert tp UTF-8 inside service. The below function works perfect for us but would like to avoid the use of depreciated escape().
function decode_utf8(bytes) {
return decodeURIComponent(escape(bytes));
}
Another reason behind avoiding escape is its not supported by TypeScript by native and we would like to go with TS.
Another way is to code the conversion routine to avoid calling escape.
Expecting suggestions on best practice. Without any changes to WCF service as its legacy and used by other systems :)