Skip to content

Instantly share code, notes, and snippets.

@felipeslongo
Created April 12, 2019 17:49
Show Gist options
  • Select an option

  • Save felipeslongo/40437fa48777f5b9328595e1d0bf181e to your computer and use it in GitHub Desktop.

Select an option

Save felipeslongo/40437fa48777f5b9328595e1d0bf181e to your computer and use it in GitHub Desktop.
Remove acentos
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