Hi all,
I have
some problems with the xsp pages and encoding. When i try to display Shift_JIS
encoded characters it is not displaying properly.
when i hard code the japnese
characters it is working properly. for example in this xsp page
<?xml version="1.0"
encoding="Shift_JIS"?>
<?cocoon-process
type="xsp"?>
<?cocoon-process
type="xslt"?>
<?xml-stylesheet
href="xsl/viewMail-to-html.xsl" type="text/xsl" ?>
<xsp:page
language="java" encoding="Shift_JIS" xmlns:xsp="http://www.apache.org/1999/XSP/Core" xmlns:request="http://www.apache.org/1999/XSP/Request" xmlns:util="http://www.apache.org/1999/XSP/Util" > <page>
<title>melpo View Mail</title> <body>
<label>‚ ‚È‚½‚ÌPC‚Ì’†‚̃[ƒ‹ƒNƒ‰ƒCƒAƒ“ƒg‚ªÄŠJ‚³‚ê‚Ü‚µ‚½B
</label>
</body>
</xsp:page>
the display html is working fine and
the characters are working properly .. but the source of the html shows
<html>
<body>
あなたのPCの中のメールクライアントが再開されました。
</body>
</html>
<!-- This page was served in 2278
milliseconds by Cocoon 1.8.2 -->
but why is the characters converted
into numbers. the problem i have here is this consumes more bytes .. so if the
device has some size limitations of the source of the page then it is a
problem. if the characters are left same way then it would consume less bytes
for the source page.
The second problem is, when i
dynamically include xml in my xsp it is not working. But the same
string when hardcode in the xsp page it is working fine.
<?xml version="1.0"
encoding="Shift_JIS"?>
<?cocoon-process
type="xsp"?>
<?cocoon-process
type="xslt"?>
<?xml-stylesheet
href="xsl/viewMail-to-html.xsl" type="text/xsl" ?>
<xsp:page
language="java" encoding="Shift_JIS" xmlns:xsp="http://www.apache.org/1999/XSP/Core" xmlns:request="http://www.apache.org/1999/XSP/Request" xmlns:util="http://www.apache.org/1999/XSP/Util" > <page>
<title>melpo View Mail</title> <body>
<xsp:logic>
String
xml = (String) request.getAttribute(xml);
<xsp:content>
<util:include-expr><util:expr>xml</util:expr></util:include-expr> // this will append an xml string like <label>‚ ‚È‚½‚ÌPC‚Ì’†‚̃[J‚³‚ê‚Ü‚µ‚½B </label>
</xsp:content>
</xsp:logic>
</body>
</xsp:page> i am getting an error
org.xml.sax.SAXException: An invalid XML character (Unicode: 0x13) was
found in the element content of the document. [FATAL ERROR] [File: "null" Line:
1 Column: 109] (nested exception: org.xml.sax.SAXParseException: An invalid XML
character (Unicode: 0x13) was found in the element content of the
document.)
But the string i am getting if hardcoded
itzworking fine. because whrn i hardcode it, the xsp page when getting compiled,
it is converting all the characters to those numbers. and whenever the string is
dynamically included the it is not
working..................................
and the third problem is ,
when i load a
string to a dom andthen get back the string the encoding information is gone.The
characers displayed are ???????????
String fullXml = "<?xml version=\"1.0\"
encoding=\"Shift_JIS\"?><Response><Message>Mail Client in your PC
has been ƒƒOƒAƒEƒg Restarted ƒGƒLƒTƒCƒg : –|–ó„—˜—p‹K–ñ xxx
</Message></Response>";
DOMParser parser = new
DOMParser();
InputStream is = new ByteArrayInputStream(fullXml.getBytes()); InputSource isource=new InputSource(is); parser.parse(isource); Document xmlDoc= parser.getDocument(); //created an dom ------------ doing some
manipulation ------------------
OutputFormat format = new OutputFormat( xmlDoc
); //Serialize DOM
StringWriter stringOut = new
StringWriter();
//Writer will be a String
XMLSerializer serial = new XMLSerializer( stringOut, format ); serial.asDOMSerializer(); // As a DOM Serializer serial.serialize( xmlDoc.getDocumentElement() ); String returnXML = stringOut.toString(); // got back the xml as String. now if i display the string "
returnXML " all the japanese characters are gone. the output is only
"???????????"
Can any of you please give a solution
for these problems, as it is very urgent for me. I have been trying to solve
theses isuues from past 2 days and have searched mail archives i was not able to
find a solution.
Thankx in Advance
regards,
Arun.N,
|
- Re: urgent encoding problem... Arun.N
- Re: urgent encoding problem... Arun.N
- RE: urgent encoding problem... Karl Øie
- Re: urgent encoding problem... Arun.N
- RE: urgent encoding problem... Karl Øie
- RE: urgent encoding problem... Karl Øie
- Re: urgent encoding problem... Arun.N
- RE: urgent encoding problem... Karl Øie