How to remove accent from string in WP7

烈酒焚心 提交于 2020-01-14 09:58:48

问题


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 ?


回答1:


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/



来源:https://stackoverflow.com/questions/13262845/how-to-remove-accent-from-string-in-wp7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!