You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
which the user agent must use to decode the bytes into <adata-link-type=dfnhref=#code-pointtitle="code points">code points</a>.
430
430
431
431
<p> To decode the stream of bytes into a stream of <adata-link-type=dfnhref=#code-pointtitle="code points">code points</a>,
432
-
UAs must follow these steps.
432
+
UAs must use the <ahref=http://encoding.spec.whatwg.org/#decode>decode</a> algorithm
433
+
defined in <adata-biblio-type=normativedata-link-type=bibliohref=#encodingtitle=encoding>[ENCODING]</a>,
434
+
with the fallback encoding determined as follows.
433
435
434
-
<p>The algorithms to <dfndata-dfn-type=dfndata-noexport="" id=get-an-encoding><ahref=http://encoding.spec.whatwg.org/#concept-encoding-get>get an encoding</a><aclass=self-linkhref=#get-an-encoding></a></dfn>
435
-
and <dfndata-dfn-type=dfndata-noexport="" id=decode><ahref=http://encoding.spec.whatwg.org/#decode>decode</a><aclass=self-linkhref=#decode></a></dfn>
436
-
are defined in <adata-biblio-type=normativedata-link-type=bibliohref=#encodingtitle=encoding>[ENCODING]</a>.
436
+
<pclass=note> Note: The <ahref=http://encoding.spec.whatwg.org/#decode>decode</a> algorithm
437
+
gives precedence to a byte order mark (BOM),
438
+
and only uses the fallback when none is found.
437
439
438
-
<p>First,<dfndata-dfn-type=dfndata-noexport="" id=determine-the-fallback-encoding>determine the fallback encoding<aclass=self-linkhref=#determine-the-fallback-encoding></a></dfn>:
440
+
<p>To<dfndata-dfn-type=dfndata-noexport="" id=determine-the-fallback-encoding>determine the fallback encoding<aclass=self-linkhref=#determine-the-fallback-encoding></a></dfn>:
439
441
440
442
<ol>
441
443
<li>
442
444
If HTTP or equivalent protocol defines an encoding (e.g. via the charset parameter of the Content-Type header),
443
-
<adata-link-type=dfnhref=#get-an-encodingtitle="get an encoding">get an encoding</a> for the specified value.
445
+
<ahref=http://encoding.spec.whatwg.org/#concept-encoding-get>get an encoding</a><adata-biblio-type=normativedata-link-type=bibliohref=#encodingtitle=encoding>[ENCODING]</a>
446
+
for the specified value.
444
447
If that does not return failure,
445
448
use the return value as the fallback encoding.
446
449
447
450
<li>
448
451
Otherwise, check the byte stream. If the first several bytes match the hex sequence
<p> then <adata-link-type=dfnhref=#get-an-encodingtitle="get an encoding">get an encoding</a> for the sequence of <code>(not 22)*</code> bytes,
454
+
<p> then <ahref=http://encoding.spec.whatwg.org/#concept-encoding-get>get an encoding</a><adata-biblio-type=normativedata-link-type=bibliohref=#encodingtitle=encoding>[ENCODING]</a>
455
+
for the sequence of <code>(not 22)*</code> bytes,
452
456
decoded per <code>windows-1252</code>.
453
457
454
-
<pclass=note> Note: Anything ASCII-compatible will do, so using <code>windows-1252</code> is fine.
458
+
<pclass=note> Note: Anything ASCII-compatible will do since valid labels are all ASCII,
459
+
so using <code>windows-1252</code> is fine.
455
460
456
461
457
462
<pclass=note> Note: The byte sequence above,
458
463
when decoded as ASCII,
459
464
is the string "<code>@charset "…";</code>",
460
-
where the "…" is the sequence of bytes corresponding to the encoding’s name.
465
+
where the "…" is the sequence of bytes corresponding to the encoding’s label.
461
466
462
467
<p> If the return value was <code>utf-16</code> or <code>utf-16be</code>,
<adata-link-type=dfnhref=#get-an-encodingtitle="get an encoding">Get an encoding</a> for the value of the <code>charset</code> attribute of the element, if any.
506
+
<ahref=http://encoding.spec.whatwg.org/#concept-encoding-get>Get an encoding</a><adata-biblio-type=normativedata-link-type=bibliohref=#encodingtitle=encoding>[ENCODING]</a>
507
+
for the value of the <code>charset</code> attribute of the element, if any.
<adata-link-type=dfnhref=#get-an-encodingtitle="get an encoding">Get an encoding</a> for the value of the <code>charset</code><ahref=http://www.w3.org/TR/xml-stylesheet/#dt-pseudo-attribute>pseudo-attribute</a> of the processing instruction, if any.
530
+
<ahref=http://encoding.spec.whatwg.org/#concept-encoding-get>Get an encoding</a><adata-biblio-type=normativedata-link-type=bibliohref=#encodingtitle=encoding>[ENCODING]</a>
531
+
for the value of the <code>charset</code><ahref=http://www.w3.org/TR/xml-stylesheet/#dt-pseudo-attribute>pseudo-attribute</a> of the processing instruction, if any.
<a>Get an encoding</a> for the value of the <code>charset</code><ahref=http://www.w3.org/TR/xml-stylesheet/#dt-pseudo-attribute>pseudo-attribute</a> of the processing instruction, if any.
370
+
<ahref="http://encoding.spec.whatwg.org/#concept-encoding-get">Get an encoding</a> [[!ENCODING]]
371
+
for the value of the <code>charset</code><ahref=http://www.w3.org/TR/xml-stylesheet/#dt-pseudo-attribute>pseudo-attribute</a> of the processing instruction, if any.
0 commit comments