- From: Jonas Sicking <jonas@sicking.cc>
- Date: Mon, 29 Jul 2013 13:16:59 -0700
- To: Takeshi Yoshino <tyoshino@google.com>
- Cc: Anne van Kesteren <annevk@annevk.nl>, Feras Moussa <feras.moussa@hotmail.com>, Travis Leithead <travis.leithead@microsoft.com>, Alex Russell <slightlyoff@google.com>, "Web Applications Working Group WG (public-webapps@w3.org)" <public-webapps@w3.org>
Couldn't we simply let the Stream class have a content type, which could contain an encoding. Then when stream.readText is called, if there's an explicit encoding, it would use that encoding when converting to text. / Jonas On Mon, Jul 29, 2013 at 6:38 AM, Takeshi Yoshino <tyoshino@google.com> wrote: > On Thu, Jul 18, 2013 at 7:22 AM, Jonas Sicking <jonas@sicking.cc> wrote: >> >> On Wed, Jul 17, 2013 at 11:46 AM, Anne van Kesteren <annevk@annevk.nl> >> wrote: >> > On Wed, Jul 17, 2013 at 11:05 AM, Jonas Sicking <jonas@sicking.cc> >> > wrote: >> >> What do you mean by "such features"? Are you saying that a Stream zip >> >> decompressor should be responsible for both decompressing as well as >> >> binary->text conversion? And thus output something other than a >> >> Stream? >> > >> > I meant that for specialized processing you'd likely want more than >> > just decoding. You mentioned HTML parsing which requires a fair amount >> > more. >> >> I don't think you want a HTML parser to do both decoding and parsing. >> That would result in a lot of code duplication in each component that >> are dealing with textual formats. >> >> > And if it's just decoding, we could extend >> > TextEncoder/TextDecoder to work with Stream objects. >> >> Sure, we can do that. The question is, what is the output from the >> TextDecoder if you pass it a Stream? A new TextStream type? Is that >> really better than adding the text-consuming functions to Stream? > > > We could introduce interfaces TextStream (readAsText) and BinaryStream > (readAsArrayBuffer) just representing as what type data can be consumed from > it. > > But for convenience, I'd like to have output of XHR to have both. Stream > should carry raw binary, charset and MIME, and present them in convenient > form (methods) to user. > > We can define convenience classes like this more generally. > - TextStreamWithOptinalTextEncoder > - BinaryStreamWithOptionalTextDecoder > There's either raw binary or text data behind it and does decoding/encoding > when necessary. What we're currently calling "Stream" and going to use for > XHR is BinaryStreamWithOptionalTextDecoder. > > TextEncoder may be defined to accept TextStream and output a BinaryStream. > TextDecoder may be defined to accept BinaryStream and output a TextStream. >
Received on Monday, 29 July 2013 20:18:06 UTC