【问题标题】:Including % with decodeURIComponent包括 % 和 decodeURIComponent
【发布时间】:2015-05-20 12:35:37
【问题描述】:

我正在创建一些以 % 作为符号和一些 URI 组件(例如 %27)的随机字符串,但我无法在 % 后面添加字符。前任。 %27。我正在使用 decodeURIComponent() 因为某些字符,例如 ' (%27)、" (%22)。

//'Hello'
decodeURIComponent('%27Hello%27');

//No Output
decodeURIComponent('%Hello%');

关于如何在字符串中包含 % 并使用 decodeURIComponent 的任何想法。

【问题讨论】:

    标签: javascript uri


    【解决方案1】:

    decodeURIComponent 用于解码encodeURIComponent 的输出,它永远不会产生'%Hello%'。你可能根本不需要打电话给decodeURIComponent

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-21
      • 1970-01-01
      • 1970-01-01
      • 2013-03-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多