W3C home > Mailing lists > Public > public-webapps@w3.org > October to December 2010

Re: XHR responseArrayBuffer attribute: suggestion to replace "asBlob" with "responseType"

From: Bjoern Hoehrmann <derhoermi@gmx.net>
Date: Thu, 11 Nov 2010 03:53:13 +0100
To: Boris Zbarsky <bzbarsky@MIT.EDU>
Cc: public-webapps@w3.org
Message-ID: <6qlmd6tc60mig7rdj5vs6qtlmaumkfhq91@hive.bjoern.hoehrmann.de>
* Boris Zbarsky wrote:
>On 11/10/10 4:39 PM, Bjoern Hoehrmann wrote:
>> In most cases you do not need to store the bytes in order to get them
>> back, you can just apply the character encoding scheme used to decode
>> the bytes to the string and you'll have the original byte string, so
>> long as the character encoding scheme is bijective, which is true for
>> most of the relevant schemes like UTF-8 and UTF-16.
>
>Neither of those is bijective.
>
>In particular, both encoding schemes are not surjective as functions 
>from Unicode strings onto byte streams (that is, there are such things 
>as invalid byte sequences for both of them).  Therefore they can't 
>possibly be bijective.  Specifically, invalid byte sequences typically 
>lead to U+FFFD ending up in the Unicode string no matter what the 
>particular values of the invalid bytes were.
>
>> like with UTF-8 encoded strings that are not-wellformed
>
>Right.  See above.  Note that most cases when the data is really desired 
>as a byte array will in fact not be valid UTF-8.

The objection that I would expect is that your decoder does not inform
higher level code whether there was an error in the stream, you do not
like to change its API, and scanning for the replacement character un-
conditionally is objectionable too; or that it's hard to come up with
good and simple rules for when to dispose of a redundant objects. That
you can't do this optimization in every last edge case, well, that does
not necessarily justify adding new XHR-like interfaces, or complicating
things for authors with new parameters and surprising behavior.
-- 
Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Am Badedeich 7 · Telefon: +49(0)160/4415681 · http://www.bjoernsworld.de
25899 Dagebüll · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/ 
Received on Thursday, 11 November 2010 02:53:54 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:41 GMT