Created
November 24, 2020 18:15
-
-
Save brunolkatz/1d8a956f0e464ec7946a90773dbb91fe to your computer and use it in GitHub Desktop.
Remove accents (PT-BR)
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
func RemoveAccents(s string) string { | |
rep := strings.NewReplacer( | |
"Š", "S", | |
"š", "s", | |
"Đ", "Dj", | |
"đ", "dj", | |
"Ž", "Z", | |
"ž", "z", | |
"Č", "C", | |
"č", "c", | |
"Ć", "C", | |
"ć", "c", | |
"À", "A", | |
"Á", "A", | |
"Â", "A", | |
"Ã", "A", | |
"Ä", "A", | |
"Å", "A", | |
"Æ", "A", | |
"Ç", "C", | |
"È", "E", | |
"É", "E", | |
"Ê", "E", | |
"Ë", "E", | |
"Ì", "I", | |
"Í", "I", | |
"Î", "I", | |
"Ï", "I", | |
"Ñ", "N", | |
"Ò", "O", | |
"Ó", "O", | |
"Ô", "O", | |
"Õ", "O", | |
"Ö", "O", | |
"Ø", "O", | |
"Ù", "U", | |
"Ú", "U", | |
"Û", "U", | |
"Ü", "U", | |
"Ý", "Y", | |
"Þ", "B", | |
"ß", "Ss", | |
"à", "a", | |
"á", "a", | |
"â", "a", | |
"ã", "a", | |
"ä", "a", | |
"å", "a", | |
"æ", "a", | |
"ç", "c", | |
"è", "e", | |
"é", "e", | |
"ê", "e", | |
"ë", "e", | |
"ì", "i", | |
"í", "i", | |
"î", "i", | |
"ï", "i", | |
"ð", "o", | |
"ñ", "n", | |
"ò", "o", | |
"ó", "o", | |
"ô", "o", | |
"õ", "o", | |
"ö", "o", | |
"ø", "o", | |
"ù", "u", | |
"ú", "u", | |
"û", "u", | |
"ý", "y", | |
"ý", "y", | |
"þ", "b", | |
"ÿ", "y", | |
"Ŕ", "R", | |
"ŕ", "r", | |
) | |
r := rep.Replace(s) | |
return r | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment