Intent to Deprecate and Remove: UTF-16 support in TextEncoder

194 views
Skip to first unread message

Joshua Bell

unread,
Apr 8, 2016, 2:54:42 PM4/8/16
to blink-dev

Primary eng (and PM) emails

jsb...@chromium.org, l.pa...@gmail.com


Summary

Remove the TextEncoder argument allowing selection of encoding; only UTF-8 will be implicitly supported.


Spec issue was: https://github.com/whatwg/encoding/issues/18

Chrome tracking bug is https://crbug.com/595351


TextDecoder remains unchanged, and supports UTF-16 along with other legacy encodings.


Motivation

The TextEncoder API never supported non-UTF encodings. Support for UTF-16 was retained from initial designs "by committee" but without explicit use cases. 


It turns out that the Web Platform doesn't need UTF-16 encoding anywhere; even pages served as UTF-16 parse URLs and submit forms as UTF-8. So it would be nice not to expose this legacy cruft, especially if no-one is actually using it.


Compatibility Risk

Firefox already made the update: https://bugzilla.mozilla.org/show_bug.cgi?id=1257877

W3C's web-platform-tests are updated as well: https://github.com/w3c/web-platform-tests/pull/2781


Alternative implementation suggestion for web developers

function encode_utf16(s, littleEndian) {

  var a = new Uint8Array(s.length * 2), view = new DataView(a.buffer);

  s.split('').forEach(function(c, i) {

    view.setUint16(i * 2, c.charCodeAt(0), littleEndian);

  });

  return a;

}


Usage information from UseCounter

https://www.chromestatus.com/metrics/feature/popularity#TextEncoderUTF16 reports 0%.


Using the raw data, the usage in stable is something like 0.00000000001% (that's a lot of zeros)


(It's likely more people will read this mail than ever used the feature.)


OWP launch tracking bug

The usage numbers are low enough that a launch tracking bug seems like overkill, but happy to file one.


Entry on the feature dashboard

The usage numbers are low enough that a dashboard entry also seems like overkill, but happy to file one.


Requesting approval to remove too?

Yes.


Philip Jägenstedt

unread,
Apr 11, 2016, 5:52:03 AM4/11/16
to Joshua Bell, blink-dev
LGTM1, one encoding to rule them all!

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.

Dimitri Glazkov

unread,
Apr 11, 2016, 10:39:05 AM4/11/16
to Philip Jägenstedt, Joshua Bell, blink-dev
LGTM2

Jochen Eisinger

unread,
Apr 11, 2016, 10:42:08 AM4/11/16
to Dimitri Glazkov, Philip Jägenstedt, Joshua Bell, blink-dev
lgtm3
Reply all
Reply to author
Forward
0 new messages