Jorge Abreu

Jorge Abreu

  • NA
  • 1
  • 0

Convert XML document to bytes - Encoding

Aug 22 2006 12:05 PM

Hi guys,

i have this piece of code, that convert my XML Document to Bytes.
private byte[] ConvertToBytes(string str)
{
 byte[] data = null;
 
 if (str != null)
 data = UTF8Encoding.UTF8.GetBytes(str);
return data;
}

When i see the document, it just eats the Portuguese characters (p.e: ç,ã, é...)
I've read a lots of documents and seems me that it could be the Encoding Type
So i tried this:

private byte[] ConvertToBytes(string str)
  {
 byte[] data = null;
   
 System.Text.UnicodeEncoding  encoding = new System.Text.UnicodeEncoding();

 if (str != null)
  encoding.EncodingName.Equals("ISO-8859-1");
  data = Encoding.Unicode.GetBytes(str);
return data;
}

But didn't solve my Problem, Have you any ideas?

kind regards
Jorge