forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-internal-encoding-binding.js
More file actions
53 lines (44 loc) · 1.83 KB
/
test-internal-encoding-binding.js
File metadata and controls
53 lines (44 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// 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), '');
}