Created
April 12, 2019 17:49
-
-
Save felipeslongo/40437fa48777f5b9328595e1d0bf181e to your computer and use it in GitHub Desktop.
Remove acentos
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Globalization; | |
| using System.Linq; | |
| using System.Text; | |
| namespace Core.Extensions | |
| { | |
| public static class String_RemoveDiacritics | |
| { | |
| public static string RemoveDiacritics(this string @this) | |
| => string.Concat( | |
| @this.Normalize(NormalizationForm.FormD) | |
| .Where(ch => | |
| CharUnicodeInfo.GetUnicodeCategory(ch) != UnicodeCategory.NonSpacingMark) | |
| ).Normalize(NormalizationForm.FormC); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment