'Alternatives to escape(string) in JavaScript

When changing to TypeScript I'm not allowed to use escape(string) anymore because it's deprecated. The reason I still use it is that the alternatives encodeURI and encodeURIComponent give a different results.

var s = "Å"
console.log(escape(s));
console.log(encodeURI(s));
console.log(encodeURIComponent(s));

I don't use this for URLs, but for a CSV export.

What are other alternatives that will give me the same result as escape(string)?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source