简体   繁体   中英

convert string to utf-8 in javascript

I am having hundeausführer (in German) text in URL and it is giving me as hundeausf%C3%BChrer in console.log. How can I convert hundeausf%C3%BChrer back to hundeausführer ?

I tried

console.log(unescape(encodeURIComponent('hundeausf%C3%BChrer')));
console.log(decodeURIComponent(escape('hundeausf%C3%BChrer')));

but not getting a proper answer in the console log. Getting the same text as hundeausf%C3%BChrer

Anyone help me to solve this out?

使用decodeURI()函数

 console.log(decodeURIComponent('hundeausf%C3%BChrer')); 

>>hundeausführer

这对我有用。

 console.log(decodeURI('hundeausf%C3%BChrer')); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM