|
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("InterchangeHeaderIdentificati on")
..WriteElementString("senderID", strSenderid)
..WriteElementString("interchangeControlReference" , strFilename)
..WriteElementString("recipientID", strReceiveId) <--- problem here .
..WriteElementString("payerID", "")
..WriteEndElement()
.............................. | |
Share:
|
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.
"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:O1**************@TK2MSFTNGP12.phx.gbl... 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("InterchangeHeaderIdentificatio n") .WriteElementString("senderID", strSenderid) .WriteElementString("interchangeControlReference", strFilename) .WriteElementString("recipientID", strReceiveId) <--- problem here . .WriteElementString("payerID", "") .WriteEndElement() .............................
| | |
thanks, my XML already got it , but still cannot output chinese character..
"Wencheng Magiya" <go*****************@hotmail.com> ¼¶¼g©ó¶l¥ó·s»D:uU**************@TK2MSFTNGP10.phx.g bl... 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.
"Agnes" <ag***@dynamictech.com.hk> wrote in message news:O1**************@TK2MSFTNGP12.phx.gbl... 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("InterchangeHeaderIdentificatio n") .WriteElementString("senderID", strSenderid) .WriteElementString("interchangeControlReference", strFilename) .WriteElementString("recipientID", strReceiveId) <--- problem here . .WriteElementString("payerID", "") .WriteEndElement() .............................
| | |
Please show how you are constructing the AMSXML writer. It should be
something like this:
new System.Xml.XmlTextWriter(filename, System.Text.Encoding.UTF8)
"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:O9**************@TK2MSFTNGP10.phx.gbl... thanks, my XML already got it , but still cannot output chinese character.. "Wencheng Magiya" <go*****************@hotmail.com> ¼¶¼g©ó¶l¥ó·s»D:uU**************@TK2MSFTNGP10.phx.g bl... 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.
"Agnes" <ag***@dynamictech.com.hk> wrote in message news:O1**************@TK2MSFTNGP12.phx.gbl... 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("InterchangeHeaderIdentificatio n") .WriteElementString("senderID", strSenderid) .WriteElementString("interchangeControlReference", strFilename) .WriteElementString("recipientID", strReceiveId) <--- problem here . .WriteElementString("payerID", "") .WriteEndElement() .............................
| | |
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()
"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:O9**************@TK2MSFTNGP10.phx.gbl... thanks, my XML already got it , but still cannot output chinese character.. "Wencheng Magiya" <go*****************@hotmail.com> glsD:uU**************@TK2MSFTNGP10.phx.gbl... 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.
"Agnes" <ag***@dynamictech.com.hk> wrote in message news:O1**************@TK2MSFTNGP12.phx.gbl... 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("InterchangeHeaderIdentificatio n") .WriteElementString("senderID", strSenderid) .WriteElementString("interchangeControlReference", strFilename) .WriteElementString("recipientID", strReceiveId) <--- problem here . .WriteElementString("payerID", "") .WriteEndElement() .............................
| | |
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" <go*****************@hotmail.com> ¼¶¼g©ó¶l¥ó·s»D:ui**************@TK2MSFTNGP14.phx.g bl... 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() "Agnes" <ag***@dynamictech.com.hk> wrote in message news:O9**************@TK2MSFTNGP10.phx.gbl... thanks, my XML already got it , but still cannot output chinese character.. "Wencheng Magiya" <go*****************@hotmail.com> glsD:uU**************@TK2MSFTNGP10.phx.gbl... 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.
"Agnes" <ag***@dynamictech.com.hk> wrote in message news:O1**************@TK2MSFTNGP12.phx.gbl... 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("InterchangeHeaderIdentificatio n") .WriteElementString("senderID", strSenderid) .WriteElementString("interchangeControlReference", strFilename) .WriteElementString("recipientID", strReceiveId) <--- problem here . .WriteElementString("payerID", "") .WriteEndElement() .............................
| | |
How big is your xml file? Can you attach it here?
"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:O5**************@TK2MSFTNGP12.phx.gbl... 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" <go*****************@hotmail.com> ¼¶¼g©ó¶l¥ó·s»D:ui**************@TK2MSFTNGP14.phx.g bl... 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() "Agnes" <ag***@dynamictech.com.hk> wrote in message news:O9**************@TK2MSFTNGP10.phx.gbl... thanks, my XML already got it , but still cannot output chinese character.. "Wencheng Magiya" <go*****************@hotmail.com> glsD:uU**************@TK2MSFTNGP10.phx.gbl... 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.
"Agnes" <ag***@dynamictech.com.hk> wrote in message news:O1**************@TK2MSFTNGP12.phx.gbl... > 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("InterchangeHeaderIdentificatio n") > .WriteElementString("senderID", strSenderid) > .WriteElementString("interchangeControlReference", strFilename) > .WriteElementString("recipientID", strReceiveId) <--- problem here . > .WriteElementString("payerID", "") > .WriteEndElement() > ............................. > >
| | |
Agnes wrote: 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"
Try this: Repeat your test using IE and set View->Encoding->Unicode
(UTF-8). Are the characters displayed now?
Cheers,
-- http://www.joergjooss.de
mailto:ne********@joergjooss.de | | |
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...lencodings.asp.
"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:O5**************@TK2MSFTNGP12.phx.gbl... 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" <go*****************@hotmail.com> ¼¶¼g©ó¶l¥ó·s»D:ui**************@TK2MSFTNGP14.phx.g bl... 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() "Agnes" <ag***@dynamictech.com.hk> wrote in message news:O9**************@TK2MSFTNGP10.phx.gbl... thanks, my XML already got it , but still cannot output chinese character.. "Wencheng Magiya" <go*****************@hotmail.com> glsD:uU**************@TK2MSFTNGP10.phx.gbl... 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.
"Agnes" <ag***@dynamictech.com.hk> wrote in message news:O1**************@TK2MSFTNGP12.phx.gbl... > 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("InterchangeHeaderIdentificatio n") > .WriteElementString("senderID", strSenderid) > .WriteElementString("interchangeControlReference", strFilename) > .WriteElementString("recipientID", strReceiveId) <--- problem here . > .WriteElementString("payerID", "") > .WriteEndElement() > ............................. > >
| | This discussion thread is closed Replies have been disabled for this discussion. Similar topics
1 post
views
Thread by Anthony Liu |
last post: by
|
3 posts
views
Thread by Coco |
last post: by
|
6 posts
views
Thread by Zhang Weiwu |
last post: by
|
2 posts
views
Thread by bob |
last post: by
|
8 posts
views
Thread by pabv |
last post: by
|
1 post
views
Thread by CYF |
last post: by
|
reply
views
Thread by Coco |
last post: by
| | | | | | | | | | | | |