gpt4 book ai didi

javascript - 在javascript中将字符串转换为utf-8

转载 作者:行者123 更新时间:2023-11-29 18:45:49 27 4
gpt4 key购买 nike

我在 URL 中有 hundeausführer(德文)文本,它在 console.log 中显示为 hundeausf%C3%BChrer。如何将 hundeausf%C3%BChrer 转换回 hundeausführer

我试过了

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

但在控制台日志中没有得到正确的答案。获取与 hundeausf%C3%BChrer

相同的文本

有人帮我解决这个问题吗?

最佳答案

使用decodeURI()函数

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

>>hundeausführer

关于javascript - 在javascript中将字符串转换为utf-8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54123174/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com