Re: how to specify Encoding

Aleksander Slominski <[email protected]>
Newsgroups gmane.text.xml.xmlpull.devel
Message-ID <[email protected]>
"Nikhil C. Khedkar" wrote:

> Hi,
>        I am using PullParser2_1_8_SMALL.jar, XPP3/MXP1
> implementation.

hi Nikhil,

they are different PullParser2_1_8_SMALL.jar is XPP2,
for XPP3 you would have xpp3_1_1_2_min.jar, ex:
http://www.extreme.indiana.edu/xgws/xsoap/xpp/download/xpp3/

>         if I want to pass InputStream to the parser's parse
> method, do I need to set the encoding of InputStream,
> equals to the attribute encoding="xyz", the xml file
> has? Or the parser takes care of this encoding and the
> InputStream need not bother about it?
>         Basically my requirement is, I want to parse xml
> file, whose encoding I do not know, using parse
> method, which takes InputStream.
>         Is the file's encoding (i.e. the one in which the
> file is saved) and the attribute, encoding="xyz" must
> be same. My question is, if the parser takes care of
> the encoding, how does it make sense from InputStream
> and fetch the encoding, because even to parse the
> first line having encoding attribute, it has to know
> the encoding of InputStream?

for simplicity current XPP3/MXP1 (or XPP2) does not do
detection  of input encoding :-(

it is not very difficult to implement but requires very careful coding
to switch during processing "raw" InputStream into appropriate encoding.

in general you can check that if XmlPull parser support encoding detection
using this feature: http://xmlpull.org/v1/doc/features.html#detect-encoding

you could try in meantime to use XNI2XmlPull that is based on Xerces2
that will do encoding detection or as with any other open source projects
if you get this fixed in XPP3 then  patch will be gratefully accepted
(and  you will be appreciated by mentioning it in docs and by other XPP3 users :-))

thanks,

alek

--
The ancestor of every action is a thought. - Ralph Waldo Emerson



To unsubscribe from this group, send an email to:
[email protected]

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.