Ambrose Leung
Ambrose Leung

Reputation: 4215

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

Upvotes: 3

Views: 2201

Answers (1)

Ambrose Leung
Ambrose Leung

Reputation: 4215

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))} )

Upvotes: 8

Related Questions