The table below lists all encodings -and their labels user agents must support. +and their labels user agents must support. User agents must not support any other encodings -or labels. +or labels.
For each encoding, ASCII-lowercasing its name yields one of its labels. -
Authors must use the UTF-8 encoding and must use the
-ASCII case-insensitive "utf-8" label to
-identify it.
+
Authors must use the UTF-8 encoding and must use its
+(ASCII case-insensitive) "utf-8" label to identify it.
-
New protocols and formats, as well as existing formats deployed in new contexts, must
-use the UTF-8 encoding exclusively. If these protocols and
-formats need to expose the encoding's name or
-label, they must expose it as "utf-8".
+
New protocols and formats, as well as existing formats deployed in new contexts, must use the
+UTF-8 encoding exclusively. If these protocols and formats need to expose the
+encoding's name or label, they must expose it
+as "utf-8".
To @@ -374,21 +373,20 @@ from a string label, run these steps:
Remove any leading and trailing ASCII whitespace from label. -
If label is an ASCII case-insensitive match for any of the labels - listed in the table below, then return the corresponding encoding; otherwise return - failure. +
If label is an ASCII case-insensitive match for any of the labels listed + in the table below, then return the corresponding encoding; otherwise return failure. -
This is a more basic and restrictive algorithm of mapping labels -to encodings than +
This is a more basic and restrictive algorithm of mapping labels to +encodings than section 1.4 of Unicode Technical Standard #22 prescribes, as that is necessary to be compatible with deployed content.
| Name - | Labels + | Name + | Labels |
|---|---|---|---|
| The Encoding | |||
"x-user-defined"
| |||
All encodings and their -labels are also available as non-normative -encodings.json resource. +
All encodings and their labels are also available as +non-normative encodings.json resource.
The set of supported encodings is primarily based on the intersection of the sets supported by major browser engines when the development of this @@ -1041,9 +1038,9 @@ optional I/O queue of bytes output (default « »), return the result
Standards are strongly discouraged from using decode, BOM sniff, and encode, except as needed for compatibility. Standards needing these legacy hooks will - most likely also need to use get an encoding (to turn a label into an - encoding) and get an output encoding (to turn an encoding into - another encoding that is suitable to pass into encode). + most likely also need to use get an encoding (to turn a label into an encoding) + and get an output encoding (to turn an encoding into another + encoding that is suitable to pass into encode).
For the extremely niche case of URL percent-encoding, custom encoder error handling is needed. The get an encoder and encode or fail algorithms are to be used for that. Other @@ -1341,7 +1338,7 @@ dictionary TextDecodeOptions { interface TextDecoder { constructor(optional DOMString label = "utf-8", optional TextDecoderOptions options = {}); - USVString decode(optional [AllowShared] BufferSource input, optional TextDecodeOptions options = {}); + USVString decode(optional AllowSharedBufferSource input, optional TextDecodeOptions options = {}); }; TextDecoder includes TextDecoderCommon; @@ -1354,10 +1351,8 @@ initially false.
decoder = new TextDecoder([label = "utf-8" [, options]])
Returns a new {{TextDecoder}} object. -
If label is either not a label or is a - label for replacement, - throws a - {{RangeError}}. +
If label is either not a label or is a label for + replacement, throws a {{RangeError}}.
decoder . encoding
Returns encoding's name, lowercased. @@ -1673,8 +1668,8 @@ TextDecoderStream includes GenericTransformStream; "utf-8" [, options]])
Returns a new {{TextDecoderStream}} object. -
If label is either not a label or is a label for replacement, - throws a {{RangeError}}. +
If label is either not a label or is a label for + replacement, throws a {{RangeError}}.
decoder . encoding
Returns encoding's name, lowercased. @@ -1695,7 +1690,7 @@ TextDecoderStream includes GenericTransformStream;
decoder . writable
Returns a writable stream which accepts
- [AllowShared] BufferSource chunks and runs
+ AllowSharedBufferSource chunks and runs
them through encoding's decoder before making them
available to {{GenericTransformStream/readable}}.
@@ -1758,7 +1753,7 @@ constructor steps are:
Let bufferSource be the result of
converting chunk to an
- [AllowShared] BufferSource.
+ AllowSharedBufferSource.
Push a copy of bufferSource to @@ -2030,9 +2025,9 @@ that are split between strings. [[!INFRA]]
A byte order mark has priority over a label as it has been found -to be more accurate in deployed content. Therefore it is not part of the UTF-8 decoder -algorithm but rather the decode and UTF-8 decode algorithms. +
A byte order mark has priority over a label as it has been found to be more accurate +in deployed content. Therefore it is not part of the UTF-8 decoder algorithm, but rather the +decode and UTF-8 decode algorithms.
UTF-8's decoder has an associated UTF-8 code point, UTF-8 bytes seen, and @@ -3253,9 +3248,9 @@ the server and the client.
A byte order mark has priority over a label as it -has been found to be more accurate in deployed content. Therefore it is not part of the -shared UTF-16 decoder algorithm but rather the decode algorithm. +
A byte order mark has priority over a label as it has been found to be more accurate +in deployed content. Therefore it is not part of the shared UTF-16 decoder algorithm, but +rather the decode algorithm.
shared UTF-16 decoder has an associated UTF-16 lead byte and UTF-16 lead surrogate (both initially null), and @@ -3331,7 +3326,7 @@ its is UTF-16BE decoder set to true.
"utf-16" is a label for UTF-16LE to deal with
+
"utf-16" is a label for UTF-16LE to deal with
deployed content.