How to pass Chinese characters from XML to a web page control

W

wtistang

I need some suggestions regarding a problem I am facing. I have a web
page (asp.net and C#) which containing Chinese characters. In my
web.config file I have:

<globalization
requestEncoding="iso-8859-1"
responseEncoding="iso-8859-1"
fileEncoding="iso-8859-1"
/>

and I also put

Response.Charset="chinese";

in the page_load event.

I hard-coded some of the Chinese characters in my aspx page and save it
using "save with encoding". The hard-coded Chinese strings look OK
when the page is loaded. My problem is when I try update some of them
with the data I got from an XML file, they become "?????????" after
the update. Here is the sample code I have:

XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("abf_c.xml"));

XmlNode myNode = doc.DocumentElement.SelectSingleNode("//Pro[@Model='"
+ lblModel.Text + "']");
string spects=myNode.InnerText.ToString();
lblSpects.Text= spects;

In debug mode I can see that spcts has the right Chinese character, but
when the page is loaded label control lblSpects conatians "????????".

Any idea how to get around it?
Thanks in advance.

MT
 
S

Sylvain Lafontaine

If I were you, I would use UTF-8 instead of from the beginning to the end,
including taking the precaution of saving files in UTF-8 with Signature.

There is also a newsgroup about localization:
microsoft.public.dotnet.internationalization .

S. L.
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top