- From: Cedric Vivier <cedricv@neonux.com>
- Date: Wed, 14 Mar 2012 16:14:04 +0800
Hi, On Wed, Mar 14, 2012 at 06:49, Jonas Sicking <jonas at sicking.cc> wrote: > Something that has come up a couple of times with content authors > lately has been the desire to convert an ArrayBuffer (or part thereof) > into a decoded string. Similarly being able to encode a string into an > ArrayBuffer (or part thereof). What are the 'late' use cases for this? The question might sound naive, but to me the encoding/decoding would have been really great to have during the time when we didn't have support for ArrayBuffers in general input/output APIs like we have now (XHR, WebSockets, File API, ...) - which sounds like the mainstream use cases to me. However there is one use case that is not supported that sounds something worthy not to overlook imho : embedding of binary data (typed arrays) into textual formats such as XML or JSON. For this, base64 encoding/decoding is typically used (so that it doesn't conflict with the XML or JSON container) and thus more or less efficiently implemented in JavaScript (just like we had to encode/decode strings in JS to/from XHR a while ago). Would it make sense to support encoding="base64" in this API? > Something as simple as > > DOMString decode(ArrayBufferView source, DOMString encoding); > ArrayBufferView encode(DOMString source, DOMString encoding, > [optional] ArrayBufferView destination); This API proposal looks lean and mean. I hope we can move the current StringEncoding proposal to something closer to this. Regards,
Received on Wednesday, 14 March 2012 01:14:04 UTC