[jdom-interest] What does the encoding really mean?
Elliotte Rusty Harold
elharo at metalab.unc.edu
Wed Nov 28 07:38:16 PST 2001
At 9:36 AM -0500 11/28/01, Fred Clewis wrote:
>Alex,
>
>When I try to use the XMLOutPutter to output UCS-2 or UCS2 (my guess at the
> java name) I get an unsupported encoding error.
>Am I doing something wrong in the code below? I have to use beta 7 in my
> situation. thanks,
>
That may mean your VM does not recognize the UCS2 or UCS-2 encoding
names. Try UTF-16 instead (which is what you should really be using
anyway.)
>SAXBuilder builder = new SAXBuilder();
>// can't use setfeature with JDOM b7
>//builder.setFeature("http://apache.org/xml/features/allow-java-encodings",
>true);
>builder.setValidation(false);
>thisDocument = builder.build(new FileInputStream(xmlFile));
>....
>ByteArrayOutputStream baos = new ByteArrayOutputStream();
>XMLOutputter xmlOut = new XMLOutputter();
>xmlOut.setEncoding("UCS-2"); // also fails UCS2
>xmlOut.output(thisDocument, baos);
>return baos.toString();
>
>java.io.UnsupportedEncodingException: UCS-2
> at java.lang.Throwable.<init>(Throwable.java:96)
> at java.lang.Exception.<init>(Exception.java:44)
> at java.io.IOException.<init>(IOException.java:49)
> at
>java.io.UnsupportedEncodingException.<init>(UnsupportedEncodingExcept
>ion.java:39)
> at sun.io.Converters.getConverterClass(Converters.java:97)
> at sun.io.Converters.newConverter(Converters.java:128)
> at
>sun.io.CharToByteConverter.getConverter(CharToByteConverter.java:71)
> at java.io.OutputStreamWriter.<init>(OutputStreamWriter.java:80)
> at org.jdom.output.XMLOutputter.makeWriter(XMLOutputter.java:451)
> at org.jdom.output.XMLOutputter.makeWriter(XMLOutputter.java:437)
> at org.jdom.output.XMLOutputter.output(XMLOutputter.java:469)
>
>_______________________________________________
>To control your jdom-interest membership:
>http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com
--
+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
| The XML Bible, 2nd Edition (Hungry Minds, 2001) |
| http://www.ibiblio.org/xml/books/bible2/ |
| http://www.amazon.com/exec/obidos/ISBN=0764547607/cafeaulaitA/ |
+----------------------------------+---------------------------------+
| Read Cafe au Lait for Java News: http://www.cafeaulait.org/ |
| Read Cafe con Leche for XML News: http://www.ibiblio.org/xml/ |
+----------------------------------+---------------------------------+
More information about the jdom-interest
mailing list