W3C home > Mailing lists > Public > whatwg@whatwg.org > March 2012

[whatwg] API for encoding/decoding ArrayBuffers into text

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Tue, 13 Mar 2012 16:38:57 -0700
Message-ID: <CAAWBYDBfk6RERUBz6VGyiCFraVhXS8VRbHitpizx8Z-fx1pxxA@mail.gmail.com>
On Tue, Mar 13, 2012 at 4:11 PM, Glenn Maynard <glenn at zewt.org> wrote:
> The API on that wiki page is a reasonable start. ?For the same reasons that
> we discussed in a recent thread (
> http://lists.w3.org/Archives/Public/public-webapps/2011JulSep/1589.html),
> conversion errors should use replacement (eg. U+FFFD), not throw
> exceptions.

Python throws errors by default, but both functions have an additional
argument specifying an alternate strategy.  In particular,
bytes.decode can either drop the invalid bytes, replace them with a
replacement char (which I agree should be U+FFFD), or replace them
with XML entities; str.encode can choose to drop characters the
encoding doesn't support.

~TJ
Received on Tuesday, 13 March 2012 16:38:57 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:40 UTC