-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Static methods for TextEncoder and TextDecoder #284
base: main
Are you sure you want to change the base?
Conversation
eacfdad
to
5286636
Compare
@@ -1333,6 +1333,10 @@ dictionary TextDecoderOptions { | |||
boolean ignoreBOM = false; | |||
}; | |||
|
|||
dictionary TextDecoderOptionsWithLabel : TextDecoderOptions { | |||
DOMString label = "utf-8"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we can get away with just supporting UTF-8 here. If you need more, you get the streaming API. Perhaps not even support fatal
or ignoreBOM
. Also makes it easier to implement without a lot of IDL bridging.
@@ -1351,13 +1357,17 @@ TextDecoder includes TextDecoderCommon; | |||
initially false. | |||
|
|||
<dl class=domintro> | |||
<dt>{{TextDecoder}} . <a method for=TextDecoder lt=decode()>decode([<var>input</var> [, <var>options</var>]])</a></code> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<dt>{{TextDecoder}} . <a method for=TextDecoder lt=decode()>decode([<var>input</var> [, <var>options</var>]])</a></code> | |
<dt><code><a>TextDecoder</a> . <a method for=TextDecoder lt=decode()>decode([<var>input</var> [, <var>options</var>]])</a></code> |
@@ -1351,13 +1357,17 @@ TextDecoder includes TextDecoderCommon; | |||
initially false. | |||
|
|||
<dl class=domintro> | |||
<dt>{{TextDecoder}} . <a method for=TextDecoder lt=decode()>decode([<var>input</var> [, <var>options</var>]])</a></code> | |||
<dd> | |||
<p>Returns the result of running <a for=TextDecoderCommon>encoding</a>'s <a for=/>decoder</a>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Below this should probably be prefixed with decoder's and here it needs some rewording as there is no instance to speak of.
constructor steps are to do nothing. | ||
|
||
<p>The <dfn method for=TextEncoder><code>encode(<var>input</var>)</code></dfn> method steps are: | ||
<p>To <a>encode an input</a> given a <a>USVString</a> <var>input</var>, run the following steps: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs <dfn>
.
<p>The | ||
<dfn method for=TextEncoder><code>encodeInto(<var>source</var>, <var>destination</var>)</code></dfn> | ||
method steps are: | ||
<p>To <a>encode a source into a destination</a> given a <a>USVString</a> <var>source</var>, and a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs <dfn>
.
@lucacasonato ... are you still wanting to push this forward. I'm interested in implementing this for both workers and node.js |
NOTE: this PR is currently blocked on a technicality (speced/bikeshed#2270).
This PR adds support for static
TextDecoder.decode
,TextEncoder.encode
andTextEncoder.encodeInto
methods. These do not add new functionality, ratherjust acting as useful helpers for "one time" text encoding/decoding operations.
Closes #267.
Preview | Diff