XML Characters not moved correctly to Data Set

G

Guest

I have a problem where the French translation for "side" gets converted
incorrectly into a datatable from XML.

Note:
The total XML is at the bottom of the message to keep from distracting from
the observation.

Note: The characters used in this example are <Text>Côtés</Text>

When I put the XML into a datatable doing either of the following it gets
converted to "C?t?s"

Method 1: "US-ASCII"
ASCIIEncoding en = new ASCIIEncoding();
byte[] XML = en.GetBytes(sWork);
MemoryStream memory_streamXLM = new
MemoryStream(XML,0,XML.Length,true,true);
DataSet ds = new DataSet();
ds.ReadXml(memory_streamXLM,System.Data.XmlReadMode.ReadSchema);

Method 2: "Unicode (UTF-8)"
UTF8Encoding utf8 = new UTF8Encoding();
Byte[] XML = utf8.GetBytes(sWork);
MemoryStream memory_streamXLM = new MemoryStream(XML);
DataSet ds = new DataSet();
ds.ReadXml(memory_streamXLM,System.Data.XmlReadMode.ReadSchema);


?ds.Tables[0].Rows[6][6]
"C?t?s"

What do I need to do?
--
Eagle Eye

Total XLM for LanguageItems

"<TableInfo>\n <xs:schema id=\"TableInfo\" xmlns=\"\"
xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"
xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\">\n <xs:element
name=\"TableInfo\" msdata:IsDataSet=\"true\">\n <xs:complexType>\n
<xs:choice maxOccurs=\"unbounded\">\n <xs:element
name=\"Table1\">\n <xs:complexType>\n <xs:sequence>\n
<xs:element name=\"LanguageItemID\"
msdata:DataType=\"System.Guid, mscorlib, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089\" type=\"xs:string\" minOccurs=\"0\" />\n
<xs:element name=\"LanguageID\" msdata:DataType=\"System.Guid,
mscorlib, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089\" type=\"xs:string\" minOccurs=\"0\" />\n
<xs:element name=\"StoreTable\" type=\"xs:string\" minOccurs=\"0\"
/>\n <xs:element name=\"RowVariable\" type=\"xs:string\"
minOccurs=\"0\" />\n <xs:element name=\"RowValue\"
type=\"xs:stri
ng\" minOccurs=\"0\" />\n <xs:element name=\"ColumnName\"
type=\"xs:string\" minOccurs=\"0\" />\n <xs:element
name=\"Text\" type=\"xs:string\" minOccurs=\"0\" />\n
<xs:element name=\"Active\" type=\"xs:boolean\" minOccurs=\"0\" />\n
<xs:element name=\"BusID\" msdata:DataType=\"System.Guid, mscorlib,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\"
type=\"xs:string\" minOccurs=\"0\" />\n <xs:element
name=\"LastUpdated\" type=\"xs:dateTime\" minOccurs=\"0\" />\n
<xs:element name=\"WebReportsTransmitted\" type=\"xs:boolean\"
minOccurs=\"0\" />\n <xs:element
name=\"WebReportsTransmitSuccessfull\" type=\"xs:boolean\" minOccurs=\"0\"
/>\n </xs:sequence>\n </xs:complexType>\n
</xs:element>\n </xs:choice>\n </xs:complexType>\n
</xs:element>\n </xs:schema>\n <Table1>\n
<LanguageItemID>030fa9ce-d6e5-4c0f-8470-0697844a7932</LanguageItemID>\n
<LanguageID>e32f05bf-466a-4b2d-821d-fef92549ae60</LanguageID>\n
<StoreTable>tblOrderType</StoreTable>\n
<RowVariable>OrderTypeID</RowVariable>\n
<RowValue>a0f5402c-77e9-45df-a586-afa111616432</RowValue>\n
<ColumnName>Ordtype_Dsc</ColumnName>\n <Text>Pickup Orders</Text>\n
<Active>true</Active>\n
<BusID>e1b68da2-4796-4240-8881-63770b19a2fc</BusID>\n
<LastUpdated>2005-10-21T09:36:08.4200000-07:00</LastUpdated>\n
<WebReportsTransmitted>false</WebReportsTransmitted>\n
<WebReportsTransmitSuccessfull>false</WebReportsTransmitSuccessfull>\n
</Table1>\n <Table1>\n
<LanguageItemID>12901025-05a9-475c-bb30-1e01fb2615a8</LanguageItemID>\n
<LanguageID>e32f05bf-466a-4b2d-821d-fef92549ae60</LanguageID>\n
<StoreTable>tblMenuPadGroup</StoreTable>\n
<RowVariable>MenuPadGroupID</RowVariable>\n
<RowValue>78441e60-80bf-40ac-889d-d4eb5f241729</RowValue>\n
<ColumnName>Menu_Pad_Grp_Label</ColumnName>\n <Text>Sides</Text>\n
<Active>true</Active>\n <BusID>e1b68da2-4796-4240-88
81-63770b19a2fc</BusID>\n
<LastUpdated>2005-10-24T21:38:29.7630000-07:00</LastUpdated>\n
<WebReportsTransmitted>false</WebReportsTransmitted>\n
<WebReportsTransmitSuccessfull>false</WebReportsTransmitSuccessfull>\n
</Table1>\n <Table1>\n
<LanguageItemID>713c969b-f50f-4162-af14-292ab5b587ca</LanguageItemID>\n
<LanguageID>34dc0255-a27e-44d2-86bb-c3591d7e41d2</LanguageID>\n
<StoreTable>tblOrderType</StoreTable>\n
<RowVariable>OrderTypeID</RowVariable>\n
<RowValue>22f35979-a34a-4d69-8911-83ff6878e63d</RowValue>\n
<ColumnName>Ordtype_Dsc</ColumnName>\n <Text>Dinez Dedans</Text>\n
<Active>true</Active>\n
<BusID>e1b68da2-4796-4240-8881-63770b19a2fc</BusID>\n
<LastUpdated>2005-10-21T09:36:08.4370000-07:00</LastUpdated>\n
<WebReportsTransmitted>false</WebReportsTransmitted>\n
<WebReportsTransmitSuccessfull>false</WebReportsTransmitSuccessfull>\n
</Table1>\n <Table1>\n
<LanguageItemID>d95fe9a1-7ea7-41b8-a1f0-6d5241478b48</LanguageItemID>\n
<LanguageID>e32f05bf-466a-
4b2d-821d-fef92549ae60</LanguageID>\n
<StoreTable>tblOrderType</StoreTable>\n
<RowVariable>OrderTypeID</RowVariable>\n
<RowValue>22f35979-a34a-4d69-8911-83ff6878e63d</RowValue>\n
<ColumnName>Ordtype_Dsc</ColumnName>\n <Text>Dine In</Text>\n
<Active>true</Active>\n
<BusID>e1b68da2-4796-4240-8881-63770b19a2fc</BusID>\n
<LastUpdated>2005-10-21T09:36:08.4370000-07:00</LastUpdated>\n
<WebReportsTransmitted>false</WebReportsTransmitted>\n
<WebReportsTransmitSuccessfull>false</WebReportsTransmitSuccessfull>\n
</Table1>\n <Table1>\n
<LanguageItemID>aa016800-62cb-4486-a533-7ef80f2fa141</LanguageItemID>\n
<LanguageID>e32f05bf-466a-4b2d-821d-fef92549ae60</LanguageID>\n
<StoreTable>tblOrderType</StoreTable>\n
<RowVariable>OrderTypeID</RowVariable>\n
<RowValue>ea167a07-d003-43b0-8e13-804cd73c2670</RowValue>\n
<ColumnName>Ordtype_Dsc</ColumnName>\n <Text>Take Out Orders</Text>\n
<Active>true</Active>\n
<BusID>e1b68da2-4796-4240-8881-63770b19a2fc</BusID>\n <LastUp
dated>2005-10-21T09:36:08.4370000-07:00</LastUpdated>\n
<WebReportsTransmitted>false</WebReportsTransmitted>\n
<WebReportsTransmitSuccessfull>false</WebReportsTransmitSuccessfull>\n
</Table1>\n <Table1>\n
<LanguageItemID>3de73137-4f45-491f-bd82-a27ec1077910</LanguageItemID>\n
<LanguageID>fb590c3c-e772-4109-8d5f-3c9d75261002</LanguageID>\n
<StoreTable>tblMenuPadGroup</StoreTable>\n
<RowVariable>MenuPadGroupID</RowVariable>\n
<RowValue>78441e60-80bf-40ac-889d-d4eb5f241729</RowValue>\n
<ColumnName>Menu_Pad_Grp_Label</ColumnName>\n <Text>Lados</Text>\n
<Active>true</Active>\n
<BusID>e1b68da2-4796-4240-8881-63770b19a2fc</BusID>\n
<LastUpdated>2005-10-24T21:38:29.9670000-07:00</LastUpdated>\n
<WebReportsTransmitted>false</WebReportsTransmitted>\n
<WebReportsTransmitSuccessfull>false</WebReportsTransmitSuccessfull>\n
</Table1>\n <Table1>\n
<LanguageItemID>02f65777-f4af-4c15-83f5-c0a395a1c4e1</LanguageItemID>\n
<LanguageID>34dc0255-a27e-44d2-86bb-c3591d7e41d2</Langua
geID>\n <StoreTable>tblMenuPadGroup</StoreTable>\n
<RowVariable>MenuPadGroupID</RowVariable>\n
<RowValue>78441e60-80bf-40ac-889d-d4eb5f241729</RowValue>\n
<ColumnName>Menu_Pad_Grp_Label</ColumnName>\n <Text>Côtés</Text>\n
<Active>true</Active>\n
<BusID>e1b68da2-4796-4240-8881-63770b19a2fc</BusID>\n
<LastUpdated>2005-10-24T23:51:17.9030000-07:00</LastUpdated>\n
<WebReportsTransmitted>false</WebReportsTransmitted>\n
<WebReportsTransmitSuccessfull>false</WebReportsTransmitSuccessfull>\n
</Table1>\n <Table1>\n
<LanguageItemID>a5534d53-8a8b-490e-9285-f69a323aa13d</LanguageItemID>\n
<LanguageID>fb590c3c-e772-4109-8d5f-3c9d75261002</LanguageID>\n
<StoreTable>tblOrderType</StoreTable>\n
<RowVariable>OrderTypeID</RowVariable>\n
<RowValue>22f35979-a34a-4d69-8911-83ff6878e63d</RowValue>\n
<ColumnName>Ordtype_Dsc</ColumnName>\n <Text>Cene Adentro</Text>\n
<Active>true</Active>\n
<BusID>e1b68da2-4796-4240-8881-63770b19a2fc</BusID>\n
<LastUpdated>2005-10-21T09:36
:08.4370000-07:00</LastUpdated>\n
<WebReportsTransmitted>false</WebReportsTransmitted>\n
<WebReportsTransmitSuccessfull>false</WebReportsTransmitSuccessfull>\n
</Table1>\n</TableInfo>"
 
K

Kevin Yu [MSFT]

Hi,

Since you are using some French characters, you cannot use the ASCII
encoding to encode the xml file. However, the UTF-8 encoding has to work.
Have you tried with Unicode (UTF-16) encoding instead?

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
C

Cor Ligthert [MVP]

Hi,

Did you just try

ds.readxml(thepath)

France is using code table 1252 as most western Europe countries or
countries which uses languages original from that use.

I hope this helps,

Cor
 
J

Jon Skeet [C# MVP]

u260044 said:
I have a problem where the French translation for "side" gets converted
incorrectly into a datatable from XML.

Note:
The total XML is at the bottom of the message to keep from distracting from
the observation.

Note: The characters used in this example are <Text>C?t?s</Text>

When I put the XML into a datatable doing either of the following it gets
converted to "C?t?s"

Method 1: "US-ASCII"
ASCIIEncoding en = new ASCIIEncoding();
byte[] XML = en.GetBytes(sWork);
MemoryStream memory_streamXLM = new
MemoryStream(XML,0,XML.Length,true,true);
DataSet ds = new DataSet();
ds.ReadXml(memory_streamXLM,System.Data.XmlReadMode.ReadSchema);

Well that certainly won't work, as accented characters aren't part of
ASCII.
Method 2: "Unicode (UTF-8)"
UTF8Encoding utf8 = new UTF8Encoding();
Byte[] XML = utf8.GetBytes(sWork);
MemoryStream memory_streamXLM = new MemoryStream(XML);
DataSet ds = new DataSet();
ds.ReadXml(memory_streamXLM,System.Data.XmlReadMode.ReadSchema);

?ds.Tables[0].Rows[6][6]
"C?t?s"

Does your XML include a full XML declaration, preferrably including the
encoding (not strictly necessary for UTF-8, but advisable)? If so, I'd
expect the latter to work.

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
 
G

Guest

Kevin,

I tried the UTF-8 again and it worked. Thanks! I tried to find something on
UTF-16 and found Unicode so tried that. It did not work when it tried to
create the dataset.

Here is the code I tried. Where did I go wrong? Recall, sWork is a fully
qualified XML statement including a full table schema.

UnicodeEncoding unicode = new UnicodeEncoding();
XML = unicode.GetBytes(sWork);
memory_streamXLM = new MemoryStream(XML,0,XML.Length,true,true);
ds = new DataSet();
ds.ReadXml(memory_streamXLM,System.Data.XmlReadMode.ReadSchema);
 
G

Guest

Creating the Small Complete Solution to demonstrate proved you were correct.
If you still want it I can provide the small solution that demonstrates the
problem and the solution.

Thanks again.
--
Eagle Eye


Jon Skeet said:
u260044 said:
I have a problem where the French translation for "side" gets converted
incorrectly into a datatable from XML.

Note:
The total XML is at the bottom of the message to keep from distracting from
the observation.

Note: The characters used in this example are <Text>C?t?s</Text>

When I put the XML into a datatable doing either of the following it gets
converted to "C?t?s"

Method 1: "US-ASCII"
ASCIIEncoding en = new ASCIIEncoding();
byte[] XML = en.GetBytes(sWork);
MemoryStream memory_streamXLM = new
MemoryStream(XML,0,XML.Length,true,true);
DataSet ds = new DataSet();
ds.ReadXml(memory_streamXLM,System.Data.XmlReadMode.ReadSchema);

Well that certainly won't work, as accented characters aren't part of
ASCII.
Method 2: "Unicode (UTF-8)"
UTF8Encoding utf8 = new UTF8Encoding();
Byte[] XML = utf8.GetBytes(sWork);
MemoryStream memory_streamXLM = new MemoryStream(XML);
DataSet ds = new DataSet();
ds.ReadXml(memory_streamXLM,System.Data.XmlReadMode.ReadSchema);

?ds.Tables[0].Rows[6][6]
"C?t?s"

Does your XML include a full XML declaration, preferrably including the
encoding (not strictly necessary for UTF-8, but advisable)? If so, I'd
expect the latter to work.

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
 
J

Jon Skeet [C# MVP]

u260044 said:
Creating the Small Complete Solution to demonstrate proved you were correct.
If you still want it I can provide the small solution that demonstrates the
problem and the solution.

No, that's okay, but thanks for the offer.
 
K

Kevin Yu [MSFT]

Hi,

Did the Unicode case throw any exceptions with any error message?

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top