Skip to content

Instantly share code, notes, and snippets.

@mamapi
Created May 16, 2017 10:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mamapi/d277fae1313221d31440d6a3247680c6 to your computer and use it in GitHub Desktop.
Save mamapi/d277fae1313221d31440d6a3247680c6 to your computer and use it in GitHub Desktop.
Remove diacritics in PowerShell
function Remove-DiacriticChars {
param ([String]$srcString = [String]::Empty)
$normalized = $srcString.Normalize( [Text.NormalizationForm]::FormD )
$sb = new-object Text.StringBuilder
$normalized.ToCharArray() | % {
if( [Globalization.CharUnicodeInfo]::GetUnicodeCategory($_) -ne [Globalization.UnicodeCategory]::NonSpacingMark) {
[void]$sb.Append($_)
}
}
$sb.ToString()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment