Skip to content

Instantly share code, notes, and snippets.

@ritalin
Last active September 28, 2017 04:35
Show Gist options
  • Save ritalin/6c0947f410f7e188212839f341db91e0 to your computer and use it in GitHub Desktop.
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.
$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