Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can i turn Turkish chars to ascii?

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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 hence sharing how it can be done in .

$posta = 'üıöçşğ'
[string]::Join('',
    $posta.Normalize([Text.NormalizationForm]::FormD).ToCharArray().
    Where{ [char]::GetUnicodeCategory($_) -ne [Globalization.UnicodeCategory]::NonSpacingMark }
).Replace("ı", "i")
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading