Closed GoogleCodeExporter closed 8 years ago
Please provide sample code and sample data, see:
http://code.google.com/p/touchcode/wiki/BugSubmission
Thanks!
Original comment by jwight
on 1 May 2009 at 7:51
Yury, John,
Attached you'll find unit tests should help to reproduce the problem.
Yury, tests are showing that the problem only happens with CXMLDocument's
initWithData:options:error:. For me,
initWithXMLString:options:error: is working fine, contrary to what your report
describes.
I went on to check NSXMLDocument. Its initWithData:options:error: doesn't parse
data which isn't proper UTF-8 but
does fine when using initWithString:options:error: much(1) like current
CXMLDocument's implementation. I ain't
seeing differences here so, this could be a won't fix in order to keep
CXMLDocument 1:1 compatible with
NSXMLDocument's API.
One workaround is to convert the NSData to NSString using the fancy encoding
and then work from there. Nevertheless, as a proof of concept, I attach a patch
to CXMLDocument that accepts encoding on its data initialiser in
order to correctly parse NSData with encodings other than UTF-8. The patch is
retro-compatible.
(1) On encoding errors, current CXMLDocument actually goes on with the parsing
and returns a document omitting
the encoding error, alas NSXMLDocument return nil document and an error. This
is subject for another issue, though.
Original comment by jpedroso@gmail.com
on 11 May 2009 at 2:04
Attachments:
Jorge, thanks for the unit tests and new method for CXMLDocument.
Hopefully people will find the new method handy - I've accepted the patch and
it is in
the repository now.
Closing this bug as fixed. Yury, please try the new API.
Original comment by jwight
on 13 May 2009 at 7:13
Oh and if you want to become a project commiter Jorge let me know. Really happy
to
add commiters who write unit tests :-)
Original comment by jwight
on 13 May 2009 at 7:15
touchJSON has the same issue. Looking through the code, I cant find a place to
make a similar modification, as
everything is using NSUTF8StringEncoding
Original comment by sircambr...@gmail.com
on 6 Jun 2009 at 12:13
nevermind :) I was using it wrong. I was using NSSting stringWithContentsOfURL,
then converting to NSData with
utf8 encoding, then feeding it to the parser, which.... "double decodes" the
utf8 ?
Original comment by sircambr...@gmail.com
on 6 Jun 2009 at 12:40
Original issue reported on code.google.com by
yurypetr...@gmail.com
on 1 May 2009 at 7:23