Last active
August 29, 2015 14:01
-
-
Save fnalin/05dbb66811784f53fa38 to your computer and use it in GitHub Desktop.
Demonstração de como pesquisar nomes com acentos
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
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var nomes = new string[] { "Luis", "Luís","Lüis" }; | |
var nome = nomes.Where(d => d.RemoverAcentosExtension() == "Luis").ToList(); | |
nome.ForEach(x => Console.WriteLine(x + "\n")); | |
} | |
} | |
static class ExemploExtension | |
{ | |
public static string RemoverAcentosExtensions(this string texto) | |
{ | |
var retorno = string.Empty; | |
if (!string.IsNullOrEmpty(texto)) | |
{ | |
byte[] bytes = Encoding.GetEncoding("iso-8859-8").GetBytes(texto); | |
retorno = Encoding.UTF8.GetString(bytes); | |
} | |
return retorno; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Para ver o código na prática, copie e cole numa app do tipo Console.
Se for divulgar o código não esqueça de me colocar nos créditos! :)
Att.
Fabiano Nalin
[email protected]
http://fabianonalin.net.br