Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unescape unicode string powershell

In PowerShell, how do unescape the unicode escaped strings?

$str1 = "http:\u002f\u002fgoogle.com\u002fsomething\u002ftest"

to

http://google.com/something/test
like image 396
Ambrose Leung Avatar asked Aug 04 '26 20:08

Ambrose Leung


1 Answers

The code to do this is:

[Regex]::Replace($str1, "\\[Uu]([0-9A-Fa-f]{4})", 
         {[char]::ToString([Convert]::ToInt32($args[0].Groups[1].Value, 16))} )
like image 127
Ambrose Leung Avatar answered Aug 07 '26 01:08

Ambrose Leung



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!