Posted By

darkbaron1912 on 12/29/11


Tagged

diacritics


Versions (?)

Loại bỏ dấu RemoveDiacritics


 / Published in: C#
 

URL: http://blogs.msdn.com/b/michkap/archive/2007/05/14/2629747.aspx

Loại bỏ dấu vd : Cộng hòa xã hội chủ nghĩa => Cong hoa xa hoi chu nghia

  1. static string RemoveDiacritics(string stIn)
  2. {
  3. string stFormD = stIn.Normalize(NormalizationForm.FormD);
  4. StringBuilder sb = new StringBuilder();
  5.  
  6. for (int ich = 0; ich < stFormD.Length; ich++)
  7. {
  8. UnicodeCategory uc = CharUnicodeInfo.GetUnicodeCategory(stFormD[ich]);
  9. if (uc != UnicodeCategory.NonSpacingMark)
  10. {
  11. sb.Append(stFormD[ich]);
  12. }
  13. }
  14.  
  15. return (sb.ToString().Normalize(NormalizationForm.FormC));
  16. }

Report this snippet  

You need to login to post a comment.