Skip to content

Commit 2977ef0

Browse files
committed
Fix encoding canonical names to match WHATWG spec
Changes both implementation and tests to use canonical encoding names: - 'ibm-866' → 'ibm866' (remove hyphen) - 'shift-jis' → 'shift_jis' (use underscore) Per WHATWG Encoding Standard, TextDecoder.encoding should return the canonical encoding name, not the label used to construct it. Fixes #5663
1 parent 6bacc75 commit 2977ef0

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/workerd/api/encoding.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace workerd::api {
1616
// the second label is the public identifier.
1717
#define EW_ENCODINGS(V) \
1818
V(Utf8, "utf-8") \
19-
V(Ibm866, "ibm-866") \
19+
V(Ibm866, "ibm866") \
2020
V(Iso8859_2, "iso-8859-2") \
2121
V(Iso8859_3, "iso-8859-3") \
2222
V(Iso8859_4, "iso-8859-4") \
@@ -49,7 +49,7 @@ namespace workerd::api {
4949
V(Big5, "big5") \
5050
V(Euc_Jp, "euc-jp") \
5151
V(Iso2022_Jp, "iso-2022-jp") \
52-
V(Shift_Jis, "shift-jis") \
52+
V(Shift_Jis, "shift_jis") \
5353
V(Euc_Kr, "euc-kr") \
5454
V(Replacement, "replacement") \
5555
V(Utf16be, "utf-16be") \

src/workerd/api/tests/encoding-test.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -401,10 +401,10 @@ export const allTheDecoders = {
401401
['utf-8', 'utf-8'],
402402
['utf8', 'utf-8'],
403403
['x-unicode20utf8', 'utf-8'],
404-
['866', 'ibm-866'],
405-
['cp866', 'ibm-866'],
406-
['csibm866', 'ibm-866'],
407-
['ibm866', 'ibm-866'],
404+
['866', 'ibm866'],
405+
['cp866', 'ibm866'],
406+
['csibm866', 'ibm866'],
407+
['ibm866', 'ibm866'],
408408
['csisolatin2', 'iso-8859-2'],
409409
['iso-8859-2', 'iso-8859-2'],
410410
['iso-ir-101', 'iso-8859-2'],
@@ -589,14 +589,14 @@ export const allTheDecoders = {
589589
['x-euc-jp', 'euc-jp'],
590590
['csiso2022jp', 'iso-2022-jp'],
591591
['iso-2022-jp', 'iso-2022-jp'],
592-
['csshiftjis', 'shift-jis'],
593-
['ms932', 'shift-jis'],
594-
['ms_kanji', 'shift-jis'],
595-
['shift-jis', 'shift-jis'],
596-
['shift_jis', 'shift-jis'],
597-
['sjis', 'shift-jis'],
598-
['windows-31j', 'shift-jis'],
599-
['x-sjis', 'shift-jis'],
592+
['csshiftjis', 'shift_jis'],
593+
['ms932', 'shift_jis'],
594+
['ms_kanji', 'shift_jis'],
595+
['shift-jis', 'shift_jis'],
596+
['shift_jis', 'shift_jis'],
597+
['sjis', 'shift_jis'],
598+
['windows-31j', 'shift_jis'],
599+
['x-sjis', 'shift_jis'],
600600
['cseuckr', 'euc-kr'],
601601
['csksc56011987', 'euc-kr'],
602602
['euc-kr', 'euc-kr'],

0 commit comments

Comments
 (0)