all groups > dotnet xml > june 2005 >
You're in the

dotnet xml

group:

XML with chinese character problem



XML with chinese character problem Agnes
6/30/2005 12:00:00 AM
dotnet xml: In my .net ,i need to generate an xml file , however, user may input a
chinese character, Then , the xml will got something unknow characters. the
following is my code, Does anyone know how to solve it ??

Private Sub Init()
With AMSXML
..Formatting = Formatting.Indented
..Indentation = 4
..IndentChar = " "
..WriteStartDocument()
..WriteDocType("SOGenericInterchange", Nothing, "SOGenericInterchange.dtd",
Nothing)
..WriteStartElement("SOGenericInterchange")
End With

End Sub
Private Sub InterchangeHeaderIdentification()
Try
With AMSXML
..WriteStartElement("InterchangeHeaderIdentification")
..WriteElementString("senderID", strSenderid)
..WriteElementString("interchangeControlReference", strFilename)
..WriteElementString("recipientID", strReceiveId) <--- problem here .
..WriteElementString("payerID", "")
..WriteEndElement()
..............................

Re: XML with chinese character problem Wencheng Magiya
6/30/2005 12:00:00 AM
In order to store non-ANSI characters in xml file, you need to define
encoding.
This first line of your xml file should be:
<?xml version="1.0" encoding="utf-8" ?>
or other encoding matches your language.

[quoted text, click to view]

Re: XML with chinese character problem Agnes
6/30/2005 12:00:00 AM
thanks, my XML already got it , but still cannot output chinese character..
"Wencheng Magiya" <gold1laser1remove1s@hotmail.com> ¼¶¼g©ó¶l¥ó·s»D:uUpGb7SfFHA.1444@TK2MSFTNGP10.phx.gbl...
[quoted text, click to view]

Re: XML with chinese character problem Wencheng Magiya
6/30/2005 12:00:00 AM
How big is your xml file? Can you attach it here?



[quoted text, click to view]

Re: XML with chinese character problem Wencheng Magiya
6/30/2005 12:00:00 AM
Agnes,

Can you put a breakpoint to see what is in strReceiveId variable?

I made a small application to test, it can write and read Chinese or other
characters OK:
Dim writer As New Xml.XmlTextWriter("test.xml", Encoding.UTF8)

writer.WriteStartDocument()

writer.WriteStartElement("node1")

writer.WriteElementString("English", TextBox1.Text)

writer.WriteElementString("Chinese", TextBox2.Text)

writer.WriteEndElement()

writer.WriteEndDocument()

writer.Flush()

writer.Close()









[quoted text, click to view]

Re: XML with chinese character problem Agnes
6/30/2005 12:00:00 AM
Dim writer As New Xml.XmlTextWriter("test.xml", Encoding.UTF8) <-- Already
Exist

IF i set breakpoint, I can see my chinese character in watch window.
However, if i use IE or notepad to read it.
The chinese character still cannot show.
"Wencheng Magiya" <gold1laser1remove1s@hotmail.com> ¼¶¼g©ó¶l¥ó·s»D:ui4rwGUfFHA.2156@TK2MSFTNGP14.phx.gbl...
[quoted text, click to view]

Re: XML with chinese character problem Chris Lovett
6/30/2005 12:00:34 AM
Please show how you are constructing the AMSXML writer. It should be
something like this:

new System.Xml.XmlTextWriter(filename, System.Text.Encoding.UTF8)

[quoted text, click to view]

Re: XML with chinese character problem Joerg Jooss
7/1/2005 12:55:37 AM
[quoted text, click to view]

Try this: Repeat your test using IE and set View->Encoding->Unicode
(UTF-8). Are the characters displayed now?

Cheers,
--
http://www.joergjooss.de
Re: XML with chinese character problem Chris Lovett
7/2/2005 11:27:10 PM
Then you are doing everything correctly. The strange characters you are
seeing in the file are probably the UTF-8 encoding of those chinese
characters, which is perfectly fine. Whoever is viewing the file must do a
corresponding UTF-8 decode.

See http://msdn.microsoft.com/library/en-us/dnxml/html/xmlencodings.asp.


[quoted text, click to view]

AddThis Social Bookmark Button