Created
March 14, 2012 19:24
-
-
Save glauco/2038839 to your computer and use it in GitHub Desktop.
Código do estagiário
This file contains 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
public string TirarAcentos(string texto) { | |
string textor = ""; | |
for (int i = 0; i < texto.Length; i++) { | |
if (texto[i].ToString() == "ã") textor += "a"; | |
else if (texto[i].ToString() == "á") textor += "a"; | |
else if (texto[i].ToString() == "à") textor += "a"; | |
else if (texto[i].ToString() == "â") textor += "a"; | |
else if (texto[i].ToString() == "ä") textor += "a"; | |
else if (texto[i].ToString() == "é") textor += "e"; | |
else if (texto[i].ToString() == "è") textor += "e"; | |
else if (texto[i].ToString() == "ê") textor += "e"; | |
else if (texto[i].ToString() == "ë") textor += "e"; | |
else if (texto[i].ToString() == "í") textor += "i"; | |
else if (texto[i].ToString() == "ì") textor += "i"; | |
else if (texto[i].ToString() == "ï") textor += "i"; | |
else if (texto[i].ToString() == "õ") textor += "o"; | |
else if (texto[i].ToString() == "ó") textor += "o"; | |
else if (texto[i].ToString() == "ò") textor += "o"; | |
else if (texto[i].ToString() == "ö") textor += "o"; | |
else if (texto[i].ToString() == "ú") textor += "u"; | |
else if (texto[i].ToString() == "ù") textor += "u"; | |
else if (texto[i].ToString() == "ü") textor += "u"; | |
else if (texto[i].ToString() == "ç") textor += "c"; | |
else if (texto[i].ToString() == "Ã") textor += "A"; | |
else if (texto[i].ToString() == "Á") textor += "A"; | |
else if (texto[i].ToString() == "À") textor += "A"; | |
else if (texto[i].ToString() == "Â") textor += "A"; | |
else if (texto[i].ToString() == "Ä") textor += "A"; | |
else if (texto[i].ToString() == "É") textor += "E"; | |
else if (texto[i].ToString() == "È") textor += "E"; | |
else if (texto[i].ToString() == "Ê") textor += "E"; | |
else if (texto[i].ToString() == "Ë") textor += "E"; | |
else if (texto[i].ToString() == "Í") textor += "I"; | |
else if (texto[i].ToString() == "Ì") textor += "I"; | |
else if (texto[i].ToString() == "Ï") textor += "I"; | |
else if (texto[i].ToString() == "Õ") textor += "O"; | |
else if (texto[i].ToString() == "Ó") textor += "O"; | |
else if (texto[i].ToString() == "Ò") textor += "O"; | |
else if (texto[i].ToString() == "Ö") textor += "O"; | |
else if (texto[i].ToString() == "Ú") textor += "U"; | |
else if (texto[i].ToString() == "Ù") textor += "U"; | |
else if (texto[i].ToString() == "Ü") textor += "U"; | |
else if (texto[i].ToString() == "Ç") textor += "C"; | |
else if (texto[i].ToString() == "`") textor += ""; | |
else if (texto[i].ToString() == "´") textor += ""; | |
else if (texto[i].ToString() == "'") textor += ""; | |
else textor += texto[i]; | |
} | |
return textor; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Poderia não ter usado expressões regulares, mas pelo menos usado um array ou uma string e ir pegando por index, como uma tabela de substituição. Iria reduzir o tamanho do código e esse monte de if em algumas linhas.