   XML encoding issue
  Hello I am encountering an issue. If anyone can help, Ive searched for 3 hrs now on the www but suggested solutions don't work. Heres what I do: reading data from SQL into a GridView, and then on a btn click, reading data from GridView and inserting it into a XML file. This works. The problem is that the resulted XML file does not want at all to be formatted as UTF-8. Meaning I get meaningless characters for Danish, Netherlands characters. Or for example the XML file writes: é instead of the spanish "e" with accent. The data is read correctly in the gridview, it is displayed correctly in there. But in the xml its as mentioned above (with errors). The code that creates the XML is this one: XmlTextWriter xWriter = new XmlTextWriter(fileName, Encoding.UTF8);It does not want to see my encoding setting. It shows no build errors but the resulted xml does not show the characters properly. I also tried this:static Encoding enc = new UTF8Encoding(false);XmlTextWriter xWriter = new XmlTextWriter(fileName, enc);this still does not work. And the funnystuff : my XML shows as utf-8 ... but the characters in it don't demonstrate it. Quote:<?xml version="1.0" encoding="utf-8" ?> How can I solve this problem?Thanks in advance.   
  Do you properly handle the encoding of the text from the gridview/SQL?   ;  Depends on what you mean exactly. Its characters show correctly in the GridView so I assumed they are recognised properly when imported from SQL. Does the GridView have a special setting for utf-8 or utf-16?Thanks.;  Sorry for being unclear. I meant which encoding do the characters use in the Gridview? If it's the OS's you might find it in the environment.If you create the XMLWriter with UTF-8 encoding i reckon you need to pass the characters UTF-8 encoded as well.   ;  I think this is it. The data is not passed from the gridview into the xml as utf-8. How can i set the encoding for a gridview?It might be a simple to solve question but I cannot find the answer on google nor msdn anywhere.   ;  I conclude you're using Java? AFAIK java's runtime uses the platforms encoding. This of course differs from OS to OS. That's why i think there ought to be a method for retrieving the VMs default encoding.   ;  My bad, I forgot to mention what language I was using. It is C#. somewhere on the road my encoding got lost... its not a big deal anyway, not a project just something I received as homework and this utf-8 thing was not mandatory. I was just curious how to solve it though, and where exactly did the encoding got lost.   ;  Ok, then System.Text.Encoding.Default looks like the information you need.   