How can i turn Turkish chars to ascii? (like ş to s)
i tried replace but it didn’t do anything.
Here some piece of my code:
$posta = $posta.ToLower()
$posta = $posta -replace "ü","u"
$posta = $posta -replace "ı","i"
$posta = $posta -replace "ö","o"
$posta = $posta -replace "ç","c"
$posta = $posta -replace "ş","s"
$posta = $posta -replace "ğ","g"
$posta = $posta.trim()
write-host $posta
if $posta was eylül it returns eylül
>Solution :
Seems like this answer combined with the comment in the same answer shows the appropriate way to do it by filtering for characters which are not NonSpacingMark followed by replacing ı with i. The answer is in c# hence sharing how it can be done in powershell.
$posta = 'üıöçşğ'
[string]::Join('',
$posta.Normalize([Text.NormalizationForm]::FormD).ToCharArray().
Where{ [char]::GetUnicodeCategory($_) -ne [Globalization.UnicodeCategory]::NonSpacingMark }
).Replace("ı", "i")