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

onm*_*133 5 string normalize diacritics non-ascii-characters windows-phone-7

我想删除从字符串口音(读音符号)在Windows Phone 7的解决方案在这里工作了.NET(桌面版).但是,WP7字符串没有Normalize方法.

有人建议从字符串改为字节,但我不知道他的意思.如何去除口音?

Mar*_*han 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);
}
Run Code Online (Sandbox Code Playgroud)

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

  • 我已经在 codeproject 上看到过它,但在 WP7 中我收到 **ISO-8859-8' 不是受支持的编码名称** (2认同)