简体   繁体   English

用百分比符号(%HH)解码十六进制字符串

[英]Decode hex string with percentage symbol (%HH)

I need to change string from this: 我需要从此更改字符串:

Fast-9%20|%20Speed%20(Something-Cool)

To this: 对此:

Fast-9 | Speed (Something-Cool)

How can I do it in NodeJS? 如何在NodeJS中做到这一点?

Refer decodeURIComponent 请参阅decodeURIComponent

The decodeURIComponent() method decodes a Uniform Resource Identifier (URI) component previously created by encodeURIComponent or by a similar routine. encodeURIComponent()方法对先前由encodeURIComponent或类似例程创建的统一资源标识符(URI)组件进行解码。

 var str = 'Fast-9%20|%20Speed%20(Something-Cool)'; alert(decodeURIComponent(str)); 

Try this: 尝试这个:

 var str = 'Fast-9%20|%20Speed%20(Something-Cool)'; str = str.replace(/%20/g, " "); alert(str); 

var decoded = decodeURIComponent("Fast-9%20|%20Speed%20(Something-Cool)");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM