decodeURIComponent抛出错误' URI格式错误'

时间:2015-01-21 09:34:26

标签: javascript jquery jquery-plugins urldecode

由于unescape已被弃用,我选择了decodeURIComponent,但它没有按预期工作。 decodeURIComponent无法解码以下URI组件

Coast%20Guard%20Academy%20to%20hold%20annual%20Women%92s%20%91Leadhership%92%20event

解码上面的字符串decodeURIComponent时会抛出一个错误,阻止剩余的javascript执行。

有没有解决方法可以解决这个问题?

1 个答案:

答案 0 :(得分:2)

使用ANSI代码页对%91%92字符进行编码。 decodeURIComponent() expects the string to have been encoded as UTF-8

  

decodeURIComponent函数计算URI的新版本,其中encodeURIComponent函数可能引入的排序的每个转义序列和UTF-8编码将替换为它表示的字符

这两个引号应编码为%E2%80%98%E2%80%99

相关问题