Last active
September 28, 2017 04:35
-
-
Save ritalin/6c0947f410f7e188212839f341db91e0 to your computer and use it in GitHub Desktop.
In Delphi dfm file, strings except for ASCII chars is express with the hash(#) + codepoint. This is a Powershell Cmdlet for convering the codepoint expression string.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$re = [regex]"#(?<cp>\d+)|'(?<chars>.+?)'" | |
function ConvertFrom-Codepoint { | |
[CmdletBinding()] | |
param ( | |
[string]$Source | |
) | |
$matches = $re.Matches($Source).Groups | ?{ $_.Success -and ($_.Name -in ('cp', 'chars')) } | |
$r = | |
foreach ($m in $matches) { | |
if ($m.Name -eq "cp") { [char]([int]$m.Value) } | |
else { [char[]]$m.Value } | |
} | |
$r -join "" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment