CSharp examples for System:String Strip
Removes accents from a string.
using System.Text.RegularExpressions; using System.Text; using System.Globalization; using System;/* w ww.ja va 2 s .c o m*/ public class Main{ #region Public Methods /// <summary> /// Removes accents from a string. /// </summary> /// <param name="value"></param> /// <returns>The result string</returns> public static string RemoveDiacritics(string value) { string stFormD = value.Normalize(NormalizationForm.FormD); StringBuilder sb = new StringBuilder(); for (int ich = 0; ich < stFormD.Length; ich++) { UnicodeCategory uc = CharUnicodeInfo.GetUnicodeCategory(stFormD[ich]); if (uc != UnicodeCategory.NonSpacingMark) { sb.Append(stFormD[ich]); } } return (sb.ToString().Normalize(NormalizationForm.FormC)); } }