You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Graham Leggett <mi...@sharp.fm> on 2005/04/28 17:27:00 UTC
Re: Windows only bug: UTFDataFormatException: Invalid byte 2 of
2-byteUTF-8 sequence
Eric Schwarzenbach said:
> Omitting all the Writer-based methods to encourage Stream usage wouldn't
> have been a bad idea either (like DocumentBuilder and SAXParser for the
> same problem on the other end). But it's a bit late now I suppose.
I would say these methods should be deprecated and removed in a future
release.
If I had seen the Writer methods were deprecated, I would never have used
them in the first place.
> Over the years, I've seen probably every programmer new to XML fall into
> the same pitfall when they try do this. "Well this is text, it makes the
> most sense to use the Writer version...", they inevitably think, and it
> often takes a lot of explaining to convince them otherwise. I shudder to
> imagine how many wrong implementations there are out there because it
> works most of the time.
I'm not new to XML, but certainly new to the subtleties of unicode. The
Principle of Least Astonishment should apply to this. There is no obvious
reason why a Writer should not be a rational choice for XML, especially
considering that a Writer is an officially supported by the
implementation. If it's not a rational choice (as has been pointed out),
then don't support it.
People have argued "it's documented", but then what programmer looks for
documentation before the fact to to solve a bug they don't even know is
there?
Regards,
Graham
--
---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org
Re: Windows only bug: UTFDataFormatException: Invalid byte 2 of 2-byteUTF-8
sequence
Posted by Joseph Kesselman <ke...@us.ibm.com>.
I think the consensus is: "Fix it in pubs." Put a stonger caveat in the
javadoc, and maybe add an entry to the FAQ or overview documents.
______________________________________
Joe Kesselman, IBM Next-Generation Web Technologies: XML, XSL and more.
"The world changed profoundly and unpredictably the day Tim Berners Lee
got bitten by a radioactive spider." -- Rafe Culpin, in r.m.filk
---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org
Re: Windows only bug: UTFDataFormatException: Invalid byte 2 of
2-byteUTF-8 sequence
Posted by Eric Schwarzenbach <Er...@alumni.upenn.edu>.
It's not that using a Writer is not a rational choice. One can imagine
situations where a Writer is perfectly rationale (where the default
encodings really are desireable, or instantiating the Writer with an
OutputStreamWriter with an explicit encoding). It's just usually
unecessary, and usually the wrong choice. And I think I was wrong,
omitting the Writer-based methods from the serializer API would have
been a bad idea. The problem is there is no Java bridge for chaining a
Writer to a stream (as far as I know).
Suppose you're not serializing to a Writer under your control, but one
provided to you by another API, and it offers a Writer but not a Stream
(probably a bad choice on the API's part, but concievable). The lack of
Writer methods on the serializer API would force you to use some
intermediary buffer and a loop through writing the bytes from the
serialized Stream to the Writer. (The same issue applies to reading the
XML in, and thus you can parse from an InputSource instantiated from a
Reader.)
As others have said, you're not dealing with a bug in any of these APIs.
A confluence of unfortunate design choices, perhaps, starting with OSes
that default to non-unicode encodings, to some aspects of Java's
Reader/Writer API. I wouldn't fault the serializer at all, except
perhaps that the caveats in the documentation should be more emphatic,
since this really IS a common pitfall.
Eric
Graham Leggett wrote:
>Eric Schwarzenbach said:
>
>
>
>>Omitting all the Writer-based methods to encourage Stream usage wouldn't
>>have been a bad idea either (like DocumentBuilder and SAXParser for the
>>same problem on the other end). But it's a bit late now I suppose.
>>
>>
>
>I would say these methods should be deprecated and removed in a future
>release.
>
>If I had seen the Writer methods were deprecated, I would never have used
>them in the first place.
>
>
>
>>Over the years, I've seen probably every programmer new to XML fall into
>>the same pitfall when they try do this. "Well this is text, it makes the
>>most sense to use the Writer version...", they inevitably think, and it
>>often takes a lot of explaining to convince them otherwise. I shudder to
>>imagine how many wrong implementations there are out there because it
>>works most of the time.
>>
>>
>
>I'm not new to XML, but certainly new to the subtleties of unicode. The
>Principle of Least Astonishment should apply to this. There is no obvious
>reason why a Writer should not be a rational choice for XML, especially
>considering that a Writer is an officially supported by the
>implementation. If it's not a rational choice (as has been pointed out),
>then don't support it.
>
>People have argued "it's documented", but then what programmer looks for
>documentation before the fact to to solve a bug they don't even know is
>there?
>
>Regards,
>Graham
>--
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
>For additional commands, e-mail: j-dev-help@xerces.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org
Re: Windows only bug: UTFDataFormatException: Invalid byte 2 of 2-byteUTF-8
sequence
Posted by Michael Glavassevich <mr...@ca.ibm.com>.
"Graham Leggett" <mi...@sharp.fm> wrote on 04/28/2005 11:27:00 AM:
> Eric Schwarzenbach said:
>
> > Omitting all the Writer-based methods to encourage Stream usage
wouldn't
> > have been a bad idea either (like DocumentBuilder and SAXParser for
the
> > same problem on the other end). But it's a bit late now I suppose.
>
> I would say these methods should be deprecated and removed in a future
> release.
I should note that these methods are required for the DOM Level 3 [1]
support (which is part of JAXP 1.3).
[1]
http://www.w3.org/TR/2004/REC-DOM-Level-3-LS-20040407/load-save.html#LS-LSOutput
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org