如何在WP7中从字符串中删除重音

时间:2012-11-07 03:43:40

标签: string windows-phone-7 diacritics normalize non-ascii-characters

我想在Windows Phone 7中删除字符串中的重音符号(变音符号)。 解决方案here适用于.NET(桌面版)。但是,WP7字符串没有Normalize方法。

Someone suggest change from string to byte,但我不知道他的意思。如何去除口音?

1 个答案:

答案 0 :(得分:4)

我用这个:

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

编辑:此解决方案适用于Windows 8应用程序,但不适用于Windows Phone。到目前为止我找到的最佳解决方案是本手册: http://invokeit.wordpress.com/2011/10/06/how-to-remove-diatrics-accent-marks-in-windows-phone-7-x/