levi
levi

Reputation: 1147

How to convert query string to hebrew letters

I have this line to get the query string from this url http://localhost:4200/אבי:

const path = location.path(true); // returns "%D7%90%D7%91%D7%99"

Can I convert it back to normal hebrew letters (in this case אבי)?

Upvotes: 2

Views: 240

Answers (1)

Pablo Lozano
Pablo Lozano

Reputation: 10342

You can use the global function decodeURI:

console.log(decodeURI("%D7%90%D7%91%D7%99"));

There is a counterpart, encodeURI to make the opposite:

console.log(encodeURI("אבי"));

Upvotes: 4

Related Questions