Best urldecode (php) way in NodeJS

So, I'm trying to decode a string that was previously specified using php in Node. About a month ago, I worked with:

querystring.unescape(str.replace(/\+/g, '%20')); 

Then it just stops working - not sure if it was an update to Node or something else. After playing around, it seems I can just use unescape (), but I'm not sure if it has not been proven yet.

 unescape(str.replace(/\+/g, '%20')); 

My question is the best way, and someone else noticed this problem. Please note that the first line works with simple lines, but it splits into odd characters - therefore, perhaps, I do not see some encoding problems.

Here's the line:

% E6.% 82% CCI-T% 8C% 01 + A

Now go to http://www.tareeinternet.com/scripts/unescape.html and decrypt it. This is my original (this is an RC4 encrypted string). I want Node to return this string.

+7
source share
1 answer

If you just use the unescape function built into Node.js, your result should be what you want.

Using Node.js 0.10.1 and Running

 unescape('%E6.%82%CCI-T%8C%01+A'); 

on the interactive shell, I get

 'æ.ÌI-T\u0001+A' 

which is very similar to what you would like to receive.

Hope this helps :-)

+29
source

All Articles