Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Issue 143943017: Added Base64 support in TextEncoder and TextDecoder. (Closed)

Created:
6 years, 11 months ago by c.shu
Modified:
6 years, 9 months ago
CC:
blink-reviews, yurys+blink_chromium.org, loislo+blink_chromium.org, adamk+blink_chromium.org, Inactive, abarth-chromium
Base URL:
https://chromium.googlesource.com/chromium/blink.git@master
Visibility:
Public.

Description

Added Base64 support in TextEncoder and TextDecoder. Base64 encoding encodes binary strings to text, which is the opposite of other text encoders, such as UTF-8. To reuse the existing APIs, use TextDecoder.decode to encode binary strings to Base64 format and use TextEncoder.encode to decode Base64 to binary string. BUG=337586

Patch Set 1 #

Total comments: 13
Unified diffs Side-by-side diffs Delta from patch set Stats (+118 lines, -32 lines) Patch
A LayoutTests/fast/encoding/api/base64.html View 1 chunk +34 lines, -0 lines 7 comments Download
A LayoutTests/fast/encoding/api/base64-expected.txt View 1 chunk +21 lines, -0 lines 0 comments Download
M LayoutTests/fast/encoding/api/encoding-labels-expected.txt View 1 chunk +3 lines, -0 lines 0 comments Download
M LayoutTests/fast/encoding/api/encoding-names.html View 1 chunk +2 lines, -1 line 0 comments Download
M LayoutTests/fast/encoding/api/encoding-names-expected.txt View 1 chunk +2 lines, -0 lines 0 comments Download
M LayoutTests/fast/encoding/api/resources/shared.js View 1 chunk +11 lines, -0 lines 0 comments Download
M Source/modules/encoding/TextEncoder.cpp View 2 chunks +3 lines, -3 lines 0 comments Download
A + Source/wtf/text/TextCodecBase64.h View 2 chunks +8 lines, -8 lines 1 comment Download
A + Source/wtf/text/TextCodecBase64.cpp View 2 chunks +26 lines, -20 lines 5 comments Download
M Source/wtf/text/TextEncoding.h View 2 chunks +2 lines, -0 lines 0 comments Download
M Source/wtf/text/TextEncodingRegistry.cpp View 2 chunks +4 lines, -0 lines 0 comments Download
M Source/wtf/wtf.gypi View 1 chunk +2 lines, -0 lines 0 comments Download

Messages

Total messages: 12 (0 generated)
c.shu
Would you review it? Thanks.
6 years, 11 months ago (2014-01-24 16:08:58 UTC) #1
jsbell
Looks like streaming is going to require a fair bit of work. https://codereview.chromium.org/143943017/diff/1/LayoutTests/fast/encoding/api/base64.html File LayoutTests/fast/encoding/api/base64.html ...
6 years, 11 months ago (2014-01-24 22:15:04 UTC) #2
jungshik at Google
Is this the right layer/API to add base64 encoder / decoder at/to ? What's the ...
6 years, 11 months ago (2014-01-27 18:24:28 UTC) #3
c.shu
On 2014/01/27 18:24:28, Jungshik Shin wrote: > Is this the right layer/API to add base64 ...
6 years, 11 months ago (2014-01-27 18:30:51 UTC) #4
jungshik at Google
> use TextDecoder.decode to encode binary strings to Base64 format and > use TextEncoder.encode to ...
6 years, 11 months ago (2014-01-27 18:31:17 UTC) #5
jsbell
On 2014/01/27 18:31:17, Jungshik Shin wrote: > Does the encoding spec require supporting this? No, ...
6 years, 11 months ago (2014-01-27 18:39:56 UTC) #6
jungshik at Google
On 2014/01/27 18:39:56, jsbell wrote: > On 2014/01/27 18:31:17, Jungshik Shin wrote: > > Does ...
6 years, 11 months ago (2014-01-27 19:30:11 UTC) #7
c.shu
> Glad to hear that we're mostly on the same page. I agree with you ...
6 years, 11 months ago (2014-01-27 20:30:30 UTC) #8
jungshik at Google
On 2014/01/27 20:30:30, c.shu wrote: > > Glad to hear that we're mostly on the ...
6 years, 10 months ago (2014-01-28 22:04:49 UTC) #9
c.shu
On 2014/01/28 22:04:49, Jungshik Shin wrote: > On 2014/01/27 20:30:30, c.shu wrote: > > > ...
6 years, 10 months ago (2014-01-29 15:15:01 UTC) #10
c.shu
> I agree. Messing up the text encoding with binary encoding, which is targeted > ...
6 years, 10 months ago (2014-01-29 15:25:29 UTC) #11
jungshik at Google
6 years, 10 months ago (2014-01-29 22:46:27 UTC) #12
On 2014/01/29 15:25:29, c.shu wrote:
> > I agree. Messing up the text encoding with binary encoding, which is
targeted
> > for data
> > transferring, is probably not a good idea. It also makes the implementation
> > complicated
> > and confusing, as I have explored.
> > So here are the possible approaches:
> > 1. Text Encoder/Decoder
> > Confusing APIs and complex implementation.
> > 2. Add Base64 APIs in ArrayBuffer
> > Seems desirable but people would like to keep the interface minimal.
> > 3. Support StringView of ArrayBuffer
> > All we need is being able to construct a StringView from an existing
> ArrayBuffer
> > 
> > and take the buffer from a StringView. Base64 encoding itself can be
> > taken care of by the existing atob/btoa.
> > Personally, I prefer option 3. But my bottom line is to have something
working
> > as I believe
> > it's a useful feature for passing data across network or across processes.
> 
> The 4th option is to enhance atob/btoa to take ArrayBuffer as an input.

I'm with you, too. Either 3rd or 4th would be nice (if it's hard to get
consensus on the 2nd).

Powered by Google App Engine
This is Rietveld 408576698