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

2024-02-24

我想从 Windows Phone 7 中的字符串中删除重音符号(变音符号)。 解决方案here https://stackoverflow.com/questions/249087/how-do-i-remove-diacritics-accents-from-a-string-in-net适用于.NET(桌面版本)。然而,WP7字符串没有Normalize method.

有人建议从字符串更改为字节 http://social.msdn.microsoft.com/Forums/en-US/wpdevelop/thread/e274873c-622d-423b-ba74-74b1fd491a78/,但我不知道他的意思。如何消除口音?


我用这个:

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/ http://invokeit.wordpress.com/2011/10/06/how-to-remove-diatrics-accent-marks-in-windows-phone-7-x/

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何从 WP7 中的字符串中删除重音符号 的相关文章

随机推荐