Static methods for TextEncoder and TextDecoder#284
Draft
lucacasonato wants to merge 1 commit intowhatwg:mainfrom
Draft
Static methods for TextEncoder and TextDecoder#284lucacasonato wants to merge 1 commit intowhatwg:mainfrom
lucacasonato wants to merge 1 commit intowhatwg:mainfrom
Conversation
eacfdad to
5286636
Compare
annevk
reviewed
Mar 14, 2023
| }; | ||
|
|
||
| dictionary TextDecoderOptionsWithLabel : TextDecoderOptions { | ||
| DOMString label = "utf-8"; |
Member
There was a problem hiding this comment.
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.
| initially false. | ||
|
|
||
| <dl class=domintro> | ||
| <dt>{{TextDecoder}} . <a method for=TextDecoder lt=decode()>decode([<var>input</var> [, <var>options</var>]])</a></code> |
Member
There was a problem hiding this comment.
Suggested change
| <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> |
| <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>. |
Member
There was a problem hiding this comment.
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: |
| <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 |
|
@lucacasonato ... are you still wanting to push this forward. I'm interested in implementing this for both workers and node.js |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NOTE: this PR is currently blocked on a technicality (speced/bikeshed#2270).
This PR adds support for static
TextDecoder.decode,TextEncoder.encodeandTextEncoder.encodeIntomethods. These do not add new functionality, ratherjust acting as useful helpers for "one time" text encoding/decoding operations.
Closes #267.
Preview | Diff