JavaScript网址解码不起作用

穆罕默德·因斯(Mehmet Ince)

我的绳子是;

var str = "Mehmet%2bAli%2b%c3%96zcan";

而且我想得到绳子;

var strDecoded = "Mehmet Ali Özcan";

我尝试了以下所有方法;

strDecoded = decodeURIComponent(str); // Fails;
strDecoded = decodeURIComponent((str + '').replace(/\+/g, '%20')); // Fails
strDecoded = _decodeURI(str); // Fails


function _decodeURI(str) {
  str = decodeURI(str);
  str = str.replace(/%27/g, "'");
  return str;
}

我还能做些什么来获得正确的字符串?任何的想法?

安德烈·迪翁

以下对我有用:

decodeURIComponent("Mehmet%2bAli%2b%c3%96zcan").replace(/\++/g, ' ');

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章