473,558 Members | 2,863 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XML with chinese character problem

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.Inde nted
..Indentation = 4
..IndentChar = " "
..WriteStartDoc ument()
..WriteDocType( "SOGenericInter change", Nothing, "SOGenericInter change.dtd",
Nothing)
..WriteStartEle ment("SOGeneric Interchange")
End With

End Sub
Private Sub InterchangeHead erIdentificatio n()
Try
With AMSXML
..WriteStartEle ment("Interchan geHeaderIdentif ication")
..WriteElementS tring("senderID ", strSenderid)
..WriteElementS tring("intercha ngeControlRefer ence", strFilename)
..WriteElementS tring("recipien tID", strReceiveId) <--- problem here .
..WriteElementS tring("payerID" , "")
..WriteEndEleme nt()
............... ...............
Nov 12 '05 #1
8 3470
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***@dynamict ech.com.hk> wrote in message
news:O1******** ******@TK2MSFTN GP12.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.Inde nted
.Indentation = 4
.IndentChar = " "
.WriteStartDocu ment()
.WriteDocType(" SOGenericInterc hange", Nothing, "SOGenericInter change.dtd",
Nothing)
.WriteStartElem ent("SOGenericI nterchange")
End With

End Sub
Private Sub InterchangeHead erIdentificatio n()
Try
With AMSXML
.WriteStartElem ent("Interchang eHeaderIdentifi cation")
.WriteElementSt ring("senderID" , strSenderid)
.WriteElementSt ring("interchan geControlRefere nce", strFilename)
.WriteElementSt ring("recipient ID", strReceiveId) <--- problem here .
.WriteElementSt ring("payerID", "")
.WriteEndElemen t()
............... ..............

Nov 12 '05 #2
thanks, my XML already got it , but still cannot output chinese character..
"Wencheng Magiya" <go************ *****@hotmail.c om> 级糶秎ン穝籇: 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***@dynamict ech.com.hk> wrote in message
news:O1******** ******@TK2MSFTN GP12.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.Inde nted
.Indentation = 4
.IndentChar = " "
.WriteStartDocu ment()
.WriteDocType(" SOGenericInterc hange", Nothing,
"SOGenericInter change.dtd",
Nothing)
.WriteStartElem ent("SOGenericI nterchange")
End With

End Sub
Private Sub InterchangeHead erIdentificatio n()
Try
With AMSXML
.WriteStartElem ent("Interchang eHeaderIdentifi cation")
.WriteElementSt ring("senderID" , strSenderid)
.WriteElementSt ring("interchan geControlRefere nce", strFilename)
.WriteElementSt ring("recipient ID", strReceiveId) <--- problem here .
.WriteElementSt ring("payerID", "")
.WriteEndElemen t()
............... ..............


Nov 12 '05 #3
Please show how you are constructing the AMSXML writer. It should be
something like this:

new System.Xml.XmlT extWriter(filen ame, System.Text.Enc oding.UTF8)

"Agnes" <ag***@dynamict ech.com.hk> wrote in message
news:O9******** ******@TK2MSFTN GP10.phx.gbl...
thanks, my XML already got it , but still cannot output chinese
character..
"Wencheng Magiya" <go************ *****@hotmail.c om>
级糶秎ン穝籇: 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***@dynamict ech.com.hk> wrote in message
news:O1******** ******@TK2MSFTN GP12.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.Inde nted
.Indentation = 4
.IndentChar = " "
.WriteStartDocu ment()
.WriteDocType(" SOGenericInterc hange", Nothing,
"SOGenericInter change.dtd",
Nothing)
.WriteStartElem ent("SOGenericI nterchange")
End With

End Sub
Private Sub InterchangeHead erIdentificatio n()
Try
With AMSXML
.WriteStartElem ent("Interchang eHeaderIdentifi cation")
.WriteElementSt ring("senderID" , strSenderid)
.WriteElementSt ring("interchan geControlRefere nce", strFilename)
.WriteElementSt ring("recipient ID", strReceiveId) <--- problem here .
.WriteElementSt ring("payerID", "")
.WriteEndElemen t()
............... ..............



Nov 12 '05 #4
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.XmlTextWrit er("test.xml", Encoding.UTF8)

writer.WriteSta rtDocument()

writer.WriteSta rtElement("node 1")

writer.WriteEle mentString("Eng lish", TextBox1.Text)

writer.WriteEle mentString("Chi nese", TextBox2.Text)

writer.WriteEnd Element()

writer.WriteEnd Document()

writer.Flush()

writer.Close()



"Agnes" <ag***@dynamict ech.com.hk> wrote in message
news:O9******** ******@TK2MSFTN GP10.phx.gbl...
thanks, my XML already got it , but still cannot output chinese
character..
"Wencheng Magiya" <go************ *****@hotmail.c om>
glsD:uU******** ******@TK2MSFTN GP10.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***@dynamict ech.com.hk> wrote in message
news:O1******** ******@TK2MSFTN GP12.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.Inde nted
.Indentation = 4
.IndentChar = " "
.WriteStartDocu ment()
.WriteDocType(" SOGenericInterc hange", Nothing,
"SOGenericInter change.dtd",
Nothing)
.WriteStartElem ent("SOGenericI nterchange")
End With

End Sub
Private Sub InterchangeHead erIdentificatio n()
Try
With AMSXML
.WriteStartElem ent("Interchang eHeaderIdentifi cation")
.WriteElementSt ring("senderID" , strSenderid)
.WriteElementSt ring("interchan geControlRefere nce", strFilename)
.WriteElementSt ring("recipient ID", strReceiveId) <--- problem here .
.WriteElementSt ring("payerID", "")
.WriteEndElemen t()
............... ..............



Nov 12 '05 #5
Dim writer As New Xml.XmlTextWrit er("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.c om> 级糶秎ン穝籇: ui************* *@TK2MSFTNGP14. phx.gbl...
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.XmlTextWrit er("test.xml", Encoding.UTF8)

writer.WriteSta rtDocument()

writer.WriteSta rtElement("node 1")

writer.WriteEle mentString("Eng lish", TextBox1.Text)

writer.WriteEle mentString("Chi nese", TextBox2.Text)

writer.WriteEnd Element()

writer.WriteEnd Document()

writer.Flush()

writer.Close()



"Agnes" <ag***@dynamict ech.com.hk> wrote in message
news:O9******** ******@TK2MSFTN GP10.phx.gbl...
thanks, my XML already got it , but still cannot output chinese
character..
"Wencheng Magiya" <go************ *****@hotmail.c om>
glsD:uU******** ******@TK2MSFTN GP10.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***@dynamict ech.com.hk> wrote in message
news:O1******** ******@TK2MSFTN GP12.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.Inde nted
.Indentation = 4
.IndentChar = " "
.WriteStartDocu ment()
.WriteDocType(" SOGenericInterc hange", Nothing,
"SOGenericInter change.dtd",
Nothing)
.WriteStartElem ent("SOGenericI nterchange")
End With

End Sub
Private Sub InterchangeHead erIdentificatio n()
Try
With AMSXML
.WriteStartElem ent("Interchang eHeaderIdentifi cation")
.WriteElementSt ring("senderID" , strSenderid)
.WriteElementSt ring("interchan geControlRefere nce", strFilename)
.WriteElementSt ring("recipient ID", strReceiveId) <--- problem here .
.WriteElementSt ring("payerID", "")
.WriteEndElemen t()
............... ..............



Nov 12 '05 #6
How big is your xml file? Can you attach it here?

"Agnes" <ag***@dynamict ech.com.hk> wrote in message
news:O5******** ******@TK2MSFTN GP12.phx.gbl...
Dim writer As New Xml.XmlTextWrit er("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.c om> 级糶秎ン穝籇: ui************* *@TK2MSFTNGP14. phx.gbl...
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.XmlTextWrit er("test.xml", Encoding.UTF8)

writer.WriteSta rtDocument()

writer.WriteSta rtElement("node 1")

writer.WriteEle mentString("Eng lish", TextBox1.Text)

writer.WriteEle mentString("Chi nese", TextBox2.Text)

writer.WriteEnd Element()

writer.WriteEnd Document()

writer.Flush()

writer.Close()



"Agnes" <ag***@dynamict ech.com.hk> wrote in message
news:O9******** ******@TK2MSFTN GP10.phx.gbl...
thanks, my XML already got it , but still cannot output chinese
character..
"Wencheng Magiya" <go************ *****@hotmail.c om>
glsD:uU******** ******@TK2MSFTN GP10.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***@dynamict ech.com.hk> wrote in message
news:O1******** ******@TK2MSFTN GP12.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.Inde nted
> .Indentation = 4
> .IndentChar = " "
> .WriteStartDocu ment()
> .WriteDocType(" SOGenericInterc hange", Nothing,
> "SOGenericInter change.dtd",
> Nothing)
> .WriteStartElem ent("SOGenericI nterchange")
> End With
>
> End Sub
> Private Sub InterchangeHead erIdentificatio n()
> Try
> With AMSXML
> .WriteStartElem ent("Interchang eHeaderIdentifi cation")
> .WriteElementSt ring("senderID" , strSenderid)
> .WriteElementSt ring("interchan geControlRefere nce", strFilename)
> .WriteElementSt ring("recipient ID", strReceiveId) <--- problem here .
> .WriteElementSt ring("payerID", "")
> .WriteEndElemen t()
> ............... ..............
>
>



Nov 12 '05 #7
Agnes wrote:
Dim writer As New Xml.XmlTextWrit er("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.d e
Nov 12 '05 #8
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***@dynamict ech.com.hk> wrote in message
news:O5******** ******@TK2MSFTN GP12.phx.gbl...
Dim writer As New Xml.XmlTextWrit er("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.c om>
级糶秎ン穝籇: ui************* *@TK2MSFTNGP14. phx.gbl...
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.XmlTextWrit er("test.xml", Encoding.UTF8)

writer.WriteSta rtDocument()

writer.WriteSta rtElement("node 1")

writer.WriteEle mentString("Eng lish", TextBox1.Text)

writer.WriteEle mentString("Chi nese", TextBox2.Text)

writer.WriteEnd Element()

writer.WriteEnd Document()

writer.Flush()

writer.Close()



"Agnes" <ag***@dynamict ech.com.hk> wrote in message
news:O9******** ******@TK2MSFTN GP10.phx.gbl...
thanks, my XML already got it , but still cannot output chinese
character..
"Wencheng Magiya" <go************ *****@hotmail.c om>
glsD:uU******** ******@TK2MSFTN GP10.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***@dynamict ech.com.hk> wrote in message
news:O1******** ******@TK2MSFTN GP12.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.Inde nted
> .Indentation = 4
> .IndentChar = " "
> .WriteStartDocu ment()
> .WriteDocType(" SOGenericInterc hange", Nothing,
> "SOGenericInter change.dtd",
> Nothing)
> .WriteStartElem ent("SOGenericI nterchange")
> End With
>
> End Sub
> Private Sub InterchangeHead erIdentificatio n()
> Try
> With AMSXML
> .WriteStartElem ent("Interchang eHeaderIdentifi cation")
> .WriteElementSt ring("senderID" , strSenderid)
> .WriteElementSt ring("interchan geControlRefere nce", strFilename)
> .WriteElementSt ring("recipient ID", strReceiveId) <--- problem here .
> .WriteElementSt ring("payerID", "")
> .WriteEndElemen t()
> ............... ..............
>
>



Nov 12 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2969
by: Anthony Liu | last post by:
The following 4 lines of code parses an XML document very well if the XML document contains only English words. But when I insert one Chinese character into the XML document, then Python starts to complain when it hits the Chinese character, saying that it is an invalid token and thus it is not well-formed. This is the complaint of...
3
3211
by: Coco | last post by:
Hi! I managed to display chinese character in my web form (.aspx), in certain situation i need to to set the text of the label of my web form in chinese character programatically which is done in my code behind. when running the web form, the character which is entered directly to the web form during design time is displayed correctly,...
6
22224
by: Zhang Weiwu | last post by:
Hello. I am working with a php software project, in it (www.egroupware.org) Chinese simplified locate is "zh" while Traditional Chinese "tw". I wish to send correct language attribute in http header, I found "zh" is not standard. I found this line in apache2's default httpd.conf # Simplified Chinese (zh-CN) AddLanguage zh-CN .zh-cn
2
2825
by: bob | last post by:
Im having a wierd chinese font issue in Access 2000. I installed the chinese support for access 2000, have all the windows stuff setup, even have 10-12 other chinese fonts installed. I made a new text field, in one of my tables. Pasted some chinese text in the field(datasheet view), and the chinese text is sideways. The chinese character...
8
11941
by: pabv | last post by:
Hello all, I am having a few issues with encoding to chinese characters and perhaps someone might be able to assist. At the moment I am only able to see chinese characters when displayed as part of a datagrid. When an input textbox is displayed it does not display chinese characters, but rather the unicode characters stored in the mssql...
1
2853
by: CYF | last post by:
My Computer : Window XP Pro English Version -> I have set the "Regional" to "Taiwan" Mysql 4.1.x -- > set to big5 already i am using C# to program. When i retrieve chinese character from the mysql database, the chinese character will become "????". Alternatively, when i insert the chinese character from the program to the database, ...
0
1445
by: Coco | last post by:
Hi! I have been searching for solution for the problem i am facing in displaying chinese character in my aspx page initially when i created the aspx page with some chinese chaarcter, it worked perfectly, but i am having problem when setting the label of my page to some chinese character during run-time which i do it from the code behind ...
0
2710
by: slchslch | last post by:
Hi all, I have search through multiple forum to look for the respective solution for this problem but still i do not find any solution to this problem. I have Samsung SGH-D520 on hand which is able to display the Chinese & Thai font on the phone menu's by using the pre-set system language. Using the same code in java J2ME game to display...
0
4088
by: kennymce | last post by:
Hi, I'm having trouble localizing my Oracle 9.2 / ASP web application for our Chinese-speaking users. My Oracle 9.2 Database has NLS_NCHAR_CHARACTERSET set to AL16UTF16. I've set up a test table thus: CREATE TABLE "TBL_TEST_CH"
0
7629
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we抣l explore What is ONU, What Is Router, ONU & Router抯 main...
0
7549
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7835
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8061
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6183
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project梡lanning, coding, testing, and deployment梬ithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3602
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3578
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2045
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
869
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.