[jdom-interest] Special characters at the beginning of XML
file.
Elliotte Rusty Harold
elharo at metalab.unc.edu
Thu Apr 17 04:25:19 PDT 2003
At 6:38 PM -0500 4/16/03, David Parker wrote:
I have seen this error twice now.
I think that they are introduced by MS Notepad.
Possibly. The file you sent does not appear to be a UTF-8 file as its
encoding declaration specifies. Rather it is a UTF-16 file. I believe
this is the Unicode format Notepad saves into.
I have looked at the file with XMLSPY version 5 release 3
and it thinks that it is well-formed and valid.
Then probably XMLSPY is in error. However, if there's some other
meta-information such as an HTTP Content-type header hanging around
somewhere that overrides the encoding declaration, it might not be.
And this is one of those annoying underspecified parts of the XML
spec. It's an error to misidentify the encoding, but it's not a fatal
error. Bleah. But most likely this is XMLSPY's failure, not ours.
Clearly it ignores the leading characters.
But I get an org.jdom.JDOMException if I attempt to create a jdom document:
this.doc = builder.build(this.input);
There is something strange about these chars in the Windows environment.
If I attempt to copy the text ( System.out.println(buffer.toString()); )
from the console window, the only thing I am able to paste is:
??<
These characters are the byte order mark 0xFFEF. They are also the
zero-width non-breaking space.
--
+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
| Processing XML with Java (Addison-Wesley, 2002) |
| http://www.cafeconleche.org/books/xmljava |
| http://www.amazon.com/exec/obidos/ISBN%3D0201771861/cafeaulaitA |
+----------------------------------+---------------------------------+
| Read Cafe au Lait for Java News: http://www.cafeaulait.org/ |
| Read Cafe con Leche for XML News: http://www.cafeconleche.org/ |
+----------------------------------+---------------------------------+
More information about the jdom-interest
mailing list