Re: asymmetry between serialzier and parser inwritingXMLDecl
Elliotte Rusty Harold <[email protected]>
| Newsgroups | gmane.text.xml.xmlpull.devel |
|---|---|
| Message-ID | <p04330106b9915cce5612@[192.168.254.4]> |
At 11:52 AM -0400 8/27/02, Aleksander Slominski wrote: > # encoding: obtained from getInputEncoding() > null if stream had unknown encoding (not set in setInputStream) > and it was not declared in XMLDecl > This one's tricky. The stream did have some encoding, even if it wasn't declared, or you couldn't have decoded it. So you might want to use "UTF-8" here instead of null. You also have to consider the possibility that the declared encoding is not the actual encoding. This is possible in the presence of external metadata such as an HTTP header which identifies the encoding. For instance, even if the document is written in SJIS while the encoding declaration specifies "UTF-16" the document might still be successfully parsed if the metadata says SJIS. -- +-----------------------+------------------------+-------------------+ | Elliotte Rusty Harold | [email protected] | Writer/Programmer | +-----------------------+------------------------+-------------------+ | XML in a Nutshell, 2nd Edition (O'Reilly, 2002) | | http://www.cafeconleche.org/books/xian2/ | | http://www.amazon.com/exec/obidos/ISBN%3D0596002920/cafeaulaitA/ | +----------------------------------+---------------------------------+ | Read Cafe au Lait for Java News: http://www.cafeaulait.org/ | | Read Cafe con Leche for XML News: http://www.cafeconleche.org/ | +----------------------------------+---------------------------------+