Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove accent from string in WP7

I want to remove accent (diacritic) from string in Windows Phone 7. The solution here works for .NET (desktop version). However, WP7 string has no Normalize method.

Someone suggest change from string to byte, but I dont know what he means. How to remove accent ?

like image 555
onmyway133 Avatar asked Oct 06 '22 02:10

onmyway133


1 Answers

I use this:

public static string RemoveAccents(this string accentedStr)
{
    byte[] tempBytes = Encoding.GetEncoding("ISO-8859-8").GetBytes(accentedStr);
    return Encoding.UTF8.GetString(tempBytes, 0, tempBytes.Length);
}

Edit: this solution works in Windows 8 apps, but not in Windows Phone. The best solution I have found so far is this manual one:
http://invokeit.wordpress.com/2011/10/06/how-to-remove-diatrics-accent-marks-in-windows-phone-7-x/

like image 199
Martin Suchan Avatar answered Oct 13 '22 10:10

Martin Suchan