问题描述
由于不推荐使用unescape
,所以我选择了decodeURIComponent
,但是它没有按预期工作. decodeURIComponent
无法解码以下URI组件
As unescape
has been deprecated I have chosen decodeURIComponent
, but it doesn't work as expected . decodeURIComponent
cant decode the following URI component
Coast%20Guard%20Academy%20to%20hold%20annual%20Women%92s%20%91Leadhership%92%20event
在解码以上字符串的解码URIComponent时,会抛出错误,从而阻止了其余的javascript执行.
While decoding the above string decodeURIComponent throws an error, which blocks the remaining javascript execution.
是否有解决此问题的解决方案?
Is there is any solution to fix this ?
推荐答案
%91
和%92
字符是使用ANSI代码页编码的. decodeURIComponent()
期望该字符串已编码为UTF-8 :
The %91
and %92
characters were encoded using an ANSI codepage. decodeURIComponent()
expects the string to have been encoded as UTF-8:
两个引号应编码为%E2%80%98
和%E2%80%99
.
这篇关于encodeURIComponent引发错误"URI格式错误"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!