mirror of
https://github.com/nodejs/node.git
synced 2025-12-28 07:50:41 +00:00
PR-URL: https://github.com/nodejs/node/pull/60893 Fixes: https://github.com/nodejs/node/issues/60888 Fixes: https://github.com/nodejs/node/issues/59515 Fixes: https://github.com/nodejs/node/issues/56542 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
54 lines
1.8 KiB
JavaScript
54 lines
1.8 KiB
JavaScript
// Flags: --expose-internals
|
||
|
||
'use strict';
|
||
|
||
require('../common');
|
||
|
||
const assert = require('node:assert');
|
||
const { internalBinding } = require('internal/test/binding');
|
||
const binding = internalBinding('encoding_binding');
|
||
|
||
// Windows-1252 specific tests
|
||
{
|
||
// Test Windows-1252 special characters in 128-159 range
|
||
// These differ from Latin-1
|
||
assert.strictEqual(binding.decodeWindows1252(Uint8Array.of(0x80), false, false), '€');
|
||
assert.strictEqual(binding.decodeWindows1252(Uint8Array.of(0x82), false, false), '‚');
|
||
assert.strictEqual(binding.decodeWindows1252(Uint8Array.of(0x83), false, false), 'ƒ');
|
||
assert.strictEqual(binding.decodeWindows1252(Uint8Array.of(0x9F), false, false), 'Ÿ');
|
||
}
|
||
|
||
{
|
||
// Test Windows-1252 characters outside 128-159 range (same as Latin-1)
|
||
const buf = Uint8Array.from([0xC1, 0xE9, 0xF3]);
|
||
assert.strictEqual(binding.decodeWindows1252(buf, false, false), 'Áéó');
|
||
}
|
||
|
||
{
|
||
// Empty input
|
||
const buf = Uint8Array.from([]);
|
||
assert.strictEqual(binding.decodeWindows1252(buf, false, false), '');
|
||
}
|
||
|
||
// Windows-1252 specific tests
|
||
{
|
||
// Test Windows-1252 special characters in 128-159 range
|
||
// These differ from Latin-1
|
||
assert.strictEqual(binding.decodeWindows1252(Uint8Array.of(0x80), false, false), '€');
|
||
assert.strictEqual(binding.decodeWindows1252(Uint8Array.of(0x82), false, false), '‚');
|
||
assert.strictEqual(binding.decodeWindows1252(Uint8Array.of(0x83), false, false), 'ƒ');
|
||
assert.strictEqual(binding.decodeWindows1252(Uint8Array.of(0x9F), false, false), 'Ÿ');
|
||
}
|
||
|
||
{
|
||
// Test Windows-1252 characters outside 128-159 range (same as Latin-1)
|
||
const buf = Uint8Array.from([0xC1, 0xE9, 0xF3]);
|
||
assert.strictEqual(binding.decodeWindows1252(buf, false, false), 'Áéó');
|
||
}
|
||
|
||
{
|
||
// Empty input
|
||
const buf = Uint8Array.from([]);
|
||
assert.strictEqual(binding.decodeWindows1252(buf, false, false), '');
|
||
}
|