Diacritic.psm1

<#
 .Synopsis
  Removes diacritic characters
 
 .Author
  Jason Bell
 
 .Description
  Removes diacritic characters from strings.
 
 .Parameter StringIn
  The string value from which to process and remove diacritic characters
 
 .Example
   # Usage with Parameter.
   Normalize-DiacriticChars -StringIn "Moisés Muñoz"
   Normalize-DiacriticChars "Moisés Muñoz"
 
 .Example
   # Usage with Pipeline
   "Moisés Muñoz" | Normalize-DiacriticChars
 
#>


function Remove-DiacriticChars 
{
    [cmdletbinding()]
    param
    (
        [Parameter(Mandatory=$true,ValueFromPipeline=$true)]
        [string]
        $StringIn
    )
    Process
    {
        Write-Verbose "Starting with : $StringIn"
        $formd = $StringIn.Normalize([System.Text.NormalizationForm]::FormD)
        Write-Verbose "Form D Conversion: $formd"
        $sb = New-Object System.Text.StringBuilder
        foreach($char in [char[]]$formd)
        {
            Write-Verbose "Processing Character $char"
            [System.Globalization.UnicodeCategory]$uc = [System.Globalization.CharUnicodeInfo]::GetUnicodeCategory($char)
            if($uc -ne [System.Globalization.UnicodeCategory]::NonSpacingMark)
            {
                $sb.Append($char) | Out-Null
            }
        }
        return $sb.ToString().Normalize([System.Text.NormalizationForm]::FormC)
    }
}

export-modulemember -function Remove-DiacriticChars