U
Urban Andersson
I try to read data from a SQL server and convert it to a xml document string
where the data itself is saved with different encodings. I figured out how
to write the correct encoding to the string but it seems that when reading
from the database the data i converted from it's original econding to UTF-8.
So when i write the xml string the result will be garbled. This is what I
have done so far could someone help me to get the data in correct encoding
from the database?
SqlConnection con = new
SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"].ToString
());
SqlDataAdapter da = new SqlDataAdapter("Select * from langlabels where
language='tr'",con);
DataSet ds = new DataSet();
da.Fill(ds);
System.IO.Stream ms = new System.IO.MemoryStream();
ds.WriteXml(ms);
byte[] ba = new byte[ms.Length];
ms.Position=0;
ms.Read(ba,0,(int)ms.Length);
String strXmlDocument =
System.Text.Encoding.GetEncoding("ISO-8859-9").GetString(ba);
where the data itself is saved with different encodings. I figured out how
to write the correct encoding to the string but it seems that when reading
from the database the data i converted from it's original econding to UTF-8.
So when i write the xml string the result will be garbled. This is what I
have done so far could someone help me to get the data in correct encoding
from the database?
SqlConnection con = new
SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"].ToString
());
SqlDataAdapter da = new SqlDataAdapter("Select * from langlabels where
language='tr'",con);
DataSet ds = new DataSet();
da.Fill(ds);
System.IO.Stream ms = new System.IO.MemoryStream();
ds.WriteXml(ms);
byte[] ba = new byte[ms.Length];
ms.Position=0;
ms.Read(ba,0,(int)ms.Length);
String strXmlDocument =
System.Text.Encoding.GetEncoding("ISO-8859-9").GetString(ba);