Created
April 8, 2013 16:33
-
-
Save leandrocustodio/5338223 to your computer and use it in GitHub Desktop.
Método para converter UTF8 para ISO-8859-1 C#
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
private string UTF8_to_ISO(string value) | |
{ | |
Encoding isoEncoding = Encoding.GetEncoding("ISO-8859-1"); | |
Encoding utfEncoding = Encoding.UTF8; | |
// Converte os bytes | |
byte[] bytesIso = utfEncoding.GetBytes(value); | |
// Obtém os bytes da string UTF | |
byte[] bytesUtf = Encoding.Convert(utfEncoding, isoEncoding, bytesIso); | |
// Obtém a string ISO a partir do array de bytes convertido | |
string textoISO = utfEncoding.GetString(bytesUtf); | |
return textoISO; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment