473,738 Members | 3,636 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 3485
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> ¼¶¼g©ó¶l¥ó·s»D: 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>
¼¶¼g©ó¶l¥ó·s»D: 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> ¼¶¼g©ó¶l¥ó·s»D: 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> ¼¶¼g©ó¶l¥ó·s»D: 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>
¼¶¼g©ó¶l¥ó·s»D: 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
2977
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 Python:
3
3230
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, while those set from code behind appear as funny character
6
22268
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
2847
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 is flipped 90degrees. Ive tried different fonts, no difference. Ive typing in characters(not...
8
11983
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 2000 server backend.
1
2873
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, those chinese character will become symbols too.
0
1456
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 i realize the chinese will displayed correctly if i opened
0
2725
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 english, chinese and thai character, the result was it failed to display any single Chinese & Thai...
0
4103
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
8969
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’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8788
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9476
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9335
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9263
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
4570
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4825
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3279
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
3
2193
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.