lib: gbk decoder is gb18030 decoder per spec

PR-URL: https://github.com/nodejs/node/pull/61099
Refs: https://encoding.spec.whatwg.org/#gbk-decoder
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
Nikita Skovoroda authored and Antoine du Hamel committed 2026-01-19 19:19:30 +01:00
1 parent c3e776becd
commit 1c0a1aa5ef
1 file changed
+3 -1
+3 -1
View File
@@ -431,7 +431,9 @@ function makeTextDecoderICU() {
#prepareConverter() {
if (this[kHandle] !== undefined) return;
const handle = getConverter(this[kEncoding], this[kFlags]);
let icuEncoding = this[kEncoding];
if (icuEncoding === 'gbk') icuEncoding = 'gb18030'; // 10.1.1. GBK's decoder is gb18030's decoder
const handle = getConverter(icuEncoding, this[kFlags]);
if (handle === undefined)
throw new ERR_ENCODING_NOT_SUPPORTED(this[kEncoding]);
this[kHandle] = handle;