Charset encoding
Marco Nätlitz <[email protected]> Mon, 28 Mar 2011 15:32:15 +0200
| Newsgroups | gmane.text.xml.sax.devel |
|---|---|
| Message-ID | <MP51425506002B582AFC2A0EBACB85469F19FC1BFBFAF29095B3DBC6A0@CVKOEXCCR.private.convista.de> |
--===============6264425099962971396==
Content-Language: de-DE
Content-Type: multipart/alternative;
boundary="_000_2AFC2A0EBACB85469F19FC1BFBFAF29095B3DBC6A0CVKOEXCCRpriv_"
--_000_2AFC2A0EBACB85469F19FC1BFBFAF29095B3DBC6A0CVKOEXCCRpriv_
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
=EF=BB=BFHi mailing list,
I am using JDom to parse XML files. If I am right, you can use SAX as a par=
ser, right?
Im currenty using this code to read in the XML file
FileInputStream fileStream =3D new FileInputStream(xmlFile);
Charset s =3D detectFileEncoding(xmlFile);
InputStreamReader streamReader =3D new InputStreamReader(fileStream=
, s);
SAXBuilder builder =3D new SAXBuilder();
doc =3D builder.build(streamReader);
The detectFileEncoding-Method is based on http://code.google.com/p/junivers=
alchardet/ and works fine so far.
I'm wondering in which charset SAXBuilder is now storing the characters its=
getting from the InputStreamReader? Currently, everything works fine and I=
am getting UTF-8 as charset no matter what I put in.
The other question would be, how I can output the XML data to file in a dif=
ferent encoding than UTF8?
Thanks for your help and regards from Germany,
Marco Naetlitz
Working Student
ConVista Consulting AG
Im Zollhafen 15/17
50678 K=C3=B6ln
Phone +49 (221) 888 26 - 331
Fax +49 (221) 888 26 - 8331
[email protected]<mailto:[email protected]>
www.ConVista.com<http://www.ConVista.com>
---------------------------------------------------------------------------=
-----
ConVista Consulting AG Geschaeftsstellen: Koeln, Muenchen, Walldorf =
Handelsregister: HRB 50609 Amtsgericht Koeln
Vorstand: Wolfgang Albers, Heiko Huelsebusch, Oliver Kewes, Thomas Moeller,=
Daniel Neubieser
Aufsichtsratsvorsitzender: Volker Meis
--_000_2AFC2A0EBACB85469F19FC1BFBFAF29095B3DBC6A0CVKOEXCCRpriv_
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
=EF=BB=BF<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:sch=
emas-microsoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:offi=
ce:word" xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=
=3D"http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=3DContent-Type content=3D"text/html; charset=3Diso-8859-1"=
>
<meta name=3DGenerator content=3D"Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.E-MailFormatvorlage17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
{page:WordSection1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=3DDE link=3Dblue vlink=3Dpurple>
<div class=3DWordSection1>
<p class=3DMsoNormal>Hi mailing list,<o:p></o:p></p>
<p class=3DMsoNormal><o:p> </o:p></p>
<p class=3DMsoNormal><span lang=3DEN-US>I am using JDom to parse XML files.=
If I am
right, you can use SAX as a parser, right?<o:p></o:p></span></p>
<p class=3DMsoNormal><span lang=3DEN-US><o:p> </o:p></span></p>
<p class=3DMsoNormal><span lang=3DEN-US>Im currenty using this code to read=
in the
XML file<o:p></o:p></span></p>
<p class=3DMsoNormal><span lang=3DEN-US><o:p> </o:p></span></p>
<p class=3DMsoNormal><span lang=3DEN-US>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0 FileInputStream fileStream =3D new
FileInputStream(xmlFile);<o:p></o:p></span></p>
<p class=3DMsoNormal><span lang=3DEN-US>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0 Charset s =3D
detectFileEncoding(xmlFile);<o:p></o:p></span></p>
<p class=3DMsoNormal><span lang=3DEN-US>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0 InputStreamReader streamReader =3D
new InputStreamReader(fileStream, s);<o:p></o:p></span></p>
<p class=3DMsoNormal><span lang=3DEN-US>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0 SAXBuilder builder =3D new
SAXBuilder();<o:p></o:p></span></p>
<p class=3DMsoNormal><span lang=3DEN-US>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0 doc =3D builder.build(streamReader);<o:p></o:p></span></p>
<p class=3DMsoNormal><span lang=3DEN-US><o:p> </o:p></span></p>
<p class=3DMsoNormal><span lang=3DEN-US>The detectFileEncoding-Method is ba=
sed on <a
href=3D"http://code.google.com/p/juniversalchardet/">http://code.google.com=
/p/juniversalchardet/</a>
and works fine so far.<o:p></o:p></span></p>
<p class=3DMsoNormal><span lang=3DEN-US><o:p> </o:p></span></p>
<p class=3DMsoNormal><span lang=3DEN-US>I’m wondering in which charse=
t
SAXBuilder is now storing the characters its getting from the InputStreamRe=
ader?
Currently, everything works fine and I am getting UTF-8 as charset no matte=
r
what I put in.<o:p></o:p></span></p>
<p class=3DMsoNormal><span lang=3DEN-US><o:p> </o:p></span></p>
<p class=3DMsoNormal><span lang=3DEN-US>The other question would be, how I =
can
output the XML data to file in a different encoding than UTF8?<o:p></o:p></=
span></p>
<p class=3DMsoNormal><span lang=3DEN-US><o:p> </o:p></span></p>
<p class=3DMsoNormal><span lang=3DEN-US>Thanks for your help and regards fr=
om
Germany,<o:p></o:p></span></p>
<p class=3DMsoNormal><span lang=3DEN-US><o:p> </o:p></span></p>
<p class=3DMsoNormal><span lang=3DEN-US style=3D'font-size:10.0pt;font-fami=
ly:"Arial","sans-serif";
color:black'><br>
Marco Naetlitz<br>
</span><span lang=3DEN-US style=3D'font-size:10.0pt;font-family:"Arial","sa=
ns-serif";
color:#5F5F5F'>Working Student<br>
</span><span lang=3DEN-US style=3D'font-size:10.0pt;font-family:"Arial","sa=
ns-serif";
color:black'><br>
</span><b><span lang=3DEN-US style=3D'font-size:10.0pt;font-family:"Arial",=
"sans-serif";
color:#004C88'>ConVista Consulting AG</span></b><span lang=3DEN-US
style=3D'font-size:10.0pt;font-family:"Arial","sans-serif";color:#004C88'><=
br>
Im Zollhafen 15/17<br>
50678 K=C3=B6ln<br>
</span><span lang=3DEN-US style=3D'font-size:10.0pt;font-family:"Arial","sa=
ns-serif";
color:black'><br>
</span><span lang=3DEN-US style=3D'font-size:10.0pt;font-family:"Arial","sa=
ns-serif";
color:#5F5F5F'>Phone +49 (221) 888 26 - 331<br>
Fax +49 (221) 888 26 - 8331<=
br>
<br>
</span><span style=3D'font-size:10.0pt;font-family:"Arial","sans-serif";
color:#5F5F5F'><a href=3D"mailto:[email protected]"><span lang=3D=
EN-US
style=3D'color:#004C88'>[email protected]</span></a></span><span
lang=3DEN-US style=3D'font-size:10.0pt;font-family:"Arial","sans-serif";col=
or:#5F5F5F'><br>
</span><span style=3D'font-size:10.0pt;font-family:"Arial","sans-serif";
color:#5F5F5F'><a href=3D"http://www.ConVista.com"><span lang=3DEN-US
style=3D'color:#004C88'>www.ConVista.com</span></a></span><span lang=3DEN-U=
S><o:p></o:p></span></p>
</div>
<div><span style=3D"cursor: auto"><br />
<font size=3D"2" face=3D"Arial"></font></a></p><font size=3D"2"><font size=
=3D"1"><hr size=3D"2" noshade=3D"true" /><font size=3D"2"><font face=3D"Ari=
al">ConVista Consulting AG Geschäf=
tsstellen: Köln, München, Walldorf &=
nbsp; Handelsregister: HRB 50609 Amtsgericht Köln<br />
Vorstand: Wolfgang Albers, Heiko Hülsebusch, Oliver Kewes, Thomas M&ou=
ml;ller, Daniel Neubieser<br />
Aufsichtsratsvorsitzender: Volker Meis</font></font></font></font></span></=
div></body>
</html>
--_000_2AFC2A0EBACB85469F19FC1BFBFAF29095B3DBC6A0CVKOEXCCRpriv_--
--===============6264425099962971396==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software
be a part of the solution? Download the Intel(R) Manageability Checker
today! http://p.sf.net/sfu/intel-dev2devmar
--===============6264425099962971396==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
List: sax-devel, [email protected]
See: http://www.saxproject.org/
https://lists.sourceforge.net/lists/listinfo/sax-devel
--===============6264425099962971396==--