1 | 'use strict';
|
2 |
|
3 | var encoding = require('../lib/encoding');
|
4 |
|
5 | exports['General tests'] = {
|
6 | 'From UTF-8 to Latin_1': function (test) {
|
7 | var input = 'ÕÄÖÜ',
|
8 | expected = Buffer.from([0xd5, 0xc4, 0xd6, 0xdc]);
|
9 | test.deepEqual(encoding.convert(input, 'latin1'), expected);
|
10 | test.done();
|
11 | },
|
12 |
|
13 | 'From Latin_1 to UTF-8': function (test) {
|
14 | var input = Buffer.from([0xd5, 0xc4, 0xd6, 0xdc]),
|
15 | expected = 'ÕÄÖÜ';
|
16 | test.deepEqual(encoding.convert(input, 'utf-8', 'latin1').toString(), expected);
|
17 | test.done();
|
18 | },
|
19 |
|
20 | 'From UTF-8 to UTF-8': function (test) {
|
21 | var input = 'ÕÄÖÜ',
|
22 | expected = Buffer.from('ÕÄÖÜ');
|
23 | test.deepEqual(encoding.convert(input, 'utf-8', 'utf-8'), expected);
|
24 | test.done();
|
25 | },
|
26 |
|
27 | 'From Latin_13 to Latin_15': function (test) {
|
28 | var input = Buffer.from([0xd5, 0xc4, 0xd6, 0xdc, 0xd0]),
|
29 | expected = Buffer.from([0xd5, 0xc4, 0xd6, 0xdc, 0xa6]);
|
30 | test.deepEqual(encoding.convert(input, 'latin_15', 'latin13'), expected);
|
31 | test.done();
|
32 | }
|
33 |
|
34 | |
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 | };
|