Home > Enterprise >  Unescape encoded string in Node (\x##)
Unescape encoded string in Node (\x##)

Time:06-10

I have the following encoded string in Node;

const test = '\x50\x77\x6b\x6d\x77\x37\x54\x43\x6f\x51\x3d\x3d'

I want to get it's unencoded value Pwkmw7TCoQ==

How can I achieve this?

CodePudding user response:

Nothing to do there. Just print the string to the console as it is.

const test = '\x50\x77\x6b\x6d\x77\x37\x54\x43\x6f\x51\x3d\x3d';
console.log(test);

'\x50\x77\x6b\x6d\x77\x37\x54\x43\x6f\x51\x3d\x3d' and 'Pwkmw7TCoQ==' are different notations for the same value.

CodePudding user response:

Use the .toString() method. It should work.

test.toString()

  • Related