Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem displaying Chinese character

Status
Not open for further replies.

slok

Programmer
Jul 2, 1999
108
SG
I'm using MSIE5.5 and MSXML v3.

Basically, if I do a File->Open from the browser,
and open the XML file, I can see the Chinese characters.

However, if I loads the XML document through a ASP script,
the Chinese characters are all replaced by question marks.

Any idea what's the problem here?

Following is my code in ASP:

===
Response.Write(&quot;<?xml version=\&quot;1.0\&quot; encoding=\&quot;UTF-8\&quot;?><html><title>loadXML</title><meta content=text/html; charset=UTF-8 />&quot;);




var dom = Server.CreateObject(&quot;MSXML2.DomDocument&quot;);
dom.async = 0;
dom.load(Server.MapPath(&quot;testexport.xml&quot;));


var parseError = dom.parseError;
if (parseError.errorCode != 0) {
var e = new Error(&quot;Error: line &quot; + parseError.line + &quot;; reason = &quot; + parseError.reason);
throw(e);
}





var root = dom.documentElement;
var e, child;
e = new Enumerator(root.childNodes);   
for (;!e.atEnd();e.moveNext())
{
child = e.item();
Response.Write(child.text + &quot;<br>&quot;);
}

=====
 
slok,

you need to have this for it too work

session.codepage = 52936


or add this the head of each asp page

<% language=vbscript codepage=52936 %>

Aaron
 
I got the following error when I add that in.

====
Error Type:
Microsoft JScript runtime (0x800A1391)
'session' is undefined
===


here's my code:

==
<%@ Language=JScript %>
<%
Response.Buffer = false;
Server.ScriptTimeout = 160;
%>

<%
session.codepage = 52936

Response.Write(&quot;<?xml version=\&quot;1.0\&quot; encoding=\&quot;UTF-8\&quot;?><html><title>loadXML</title><meta content=text/html; charset=UTF-8 />&quot;);


var dom = Server.CreateObject(&quot;MSXML2.DomDocument&quot;);
dom.async = 0;
dom.load(Server.MapPath(&quot;testexport.xml&quot;));


var parseError = dom.parseError;
if (parseError.errorCode != 0) {
var e = new Error(&quot;Error: line &quot; + parseError.line + &quot;; reason = &quot; + parseError.reason);
throw(e);
}



var root = dom.documentElement;
var e, child;
e = new Enumerator(root.childNodes);  
for (;!e.atEnd();e.moveNext())
{
child = e.item();
Response.Write(child.text + &quot;<br>&quot;);
}



Response.Write(&quot;1<br>&quot;);

==
 
<% language=JScript codepage=65001 %>

I got the work around. Pls see my above code and
the codepage value.

thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top