由于不推荐使用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:
decodeURIComponent函数计算URI的新版本,其中encodeURIComponent函数可能引入的每种转义序列和UTF-8编码类型的编码都将替换为其表示的字符.
The decodeURIComponent function computes a new version of a URI in which each escape sequence and UTF-8 encoding of the sort that might be introduced by the encodeURIComponent function is replaced with the character that it represents.
两个引号应编码为%E2%80%98和%E2%80%99.
更多推荐
encodeURIComponent引发错误"URI格式错误"
发布评论