How to decode this string in javascript

Asked

Viewed 187 times

2

I get this string on frontend, but I need to decode it.

Tr%E1%BA%A7n_H%C6%B0ng_%C4%90%E1%BA%A1o -> Trần Hưng Đạo

I don’t know any function to decode it.

  • Although it is in English, and of course it is not our obligation but of those who asked, it was easy to understand and easy to translate, instead of voting to close, could very well have translated it

  • It was my fault, not for evil. I’ll take care of it next time. I’m sorry.

  • I thought I was on stackoverflow in English, my apologies.

1 answer

5


Try to use the function decodeURIComponent:

conteudo = "Tr%E1%BA%A7n_H%C6%B0ng_%C4%90%E1%BA%A1o"

console.log(decodeURIComponent(conteudo))

  • Wouldn’t it be better to use the function decodeURIComponent, since the string is not a complete URI but a part of it?

  • It worked, but I think for the comma and two points did not work in the case of the word: Music_of_austin%2C_Texas that would be a comma

  • With Component worked with the commas and two points

Browser other questions tagged

You are not signed in. Login or sign up in order to post.