# encoding: utf-8
# api: powershell
# title: Remove diacritics
# description: Remove diacritics from string :
# version: 0.1
# type: function
# author: Grgory Schiro
# license: CC0
# function: Remove-Diacritics
# x-poshcode-id: 1054
# x-archived: 2017-05-13T16:17:56
# x-published: 2009-04-23T05:52:00
#
# PS> Remove-Diacritics -String ‘éàçèöîïñùà’
# eaceoiinua
#
### Grégory Schiro, 2009
### <summary>
### Removes diacritics from string.
### </summary>
### <param name="String">String containing diacritics</param>
function Remove-Diacritics([string]$String)
{
$objD = $String.Normalize([Text.NormalizationForm]::FormD)
$sb = New-Object Text.StringBuilder
for ($i = 0; $i -lt $objD.Length; $i++) {
$c = [Globalization.CharUnicodeInfo]::GetUnicodeCategory($objD[$i])
if($c -ne [Globalization.UnicodeCategory]::NonSpacingMark) {
[void]$sb.Append($objD[$i])
}
}
return("$sb".Normalize([Text.NormalizationForm]::FormC))
}