Re: Overlap between StreamReader and FileReader

On Tue, Jul 30, 2013 at 12:07 PM, Jonas Sicking <jonas@sicking.cc> wrote:

> >> could contain an encoding. Then when stream.readText is called, if
> >> there's an explicit encoding, it would use that encoding when
> >
> >
> > Do you think it should also have overrideMimeType like XHR?
>
> I think that use case is rare enough that we can solve it by letting the
> author create a new Stream object, which presumably would allow specifying
> a type for that stream, and then feed that new stream the contents of the
> old stream.
>
OK.

One question about readText is what size should mean and how to handle
incomplete chunk.

a) maxSize means the size of DOMString. readText reads data until it builds
DOMString of maxSize or reached EoF
b) maxSize means the size of raw bytes
b-i) buffer incomplete bytes for next read
b-ii) fail if decoder didn't consume all read data (of maxSize bytes)

b-ii) is simple but inconvenient. user need to know the number of bytes the
next text data occupies in advance

maybe b-i) and in case read() is issued after incomplete readText, an
exception should be thrown. This is kind of mutual exclusiveness Anne was
worrying about.

Received on Wednesday, 31 July 2013 05:27:57 UTC