summaryrefslogtreecommitdiff
path: root/zap/src/mem/win1252dec.c
blob: 2a5e897e3e5ebf30f7b52311872e8e7fae260270 (plain) (blame)
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
	Copyright 2022 Gabriel Jensen.
	This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
	If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

#include <zap/priv.h>

#include <zap/mem.h>

void zap_win1252dec(zap_chr8 const * const _in,zap_chr20 * const _out) {
	zap_chr8 const * in  = _in;
	zap_chr20 *      out = _out;
	for (;;++in,++out) {
		zap_chr8 const chr = *in;
		switch (chr) {
		default:
			*out = *in;
			break;
		case 0x81: /* Bad characters. */
		case 0x8D:
		case 0x8F:
		case 0x90:
		case 0x9D:
			*out = 0xFFFDu; /* REPLACEMENT CHARACTER */
			break;
		case 0x80:
			*out = 0x20ACu;
			break;
		case 0x82:
			*out = 0x201Au;
			break;
		case 0x83:
			*out = 0x192u;
			break;
		case 0x84:
			*out = 0x201Eu;
			break;
		case 0x85:
			*out = 0x2026u;
			break;
		case 0x86:
			*out = 0x2020u;
			break;
		case 0x87:
			*out = 0x2021u;
			break;
		case 0x88:
			*out = 0x2C6u;
			break;
		case 0x89:
			*out = 0x2030u;
			break;
		case 0x8A:
			*out = 0x160u;
			break;
		case 0x8B:
			*out = 0x2039u;
			break;
		case 0x8C:
			*out = 0x152u;
			break;
		case 0x8E:
			*out = 0x17Du;
			break;
		case 0x91:
			*out = 0x2018u;
			break;
		case 0x92:
			*out = 0x2019u;
			break;
		case 0x93:
			*out = 0x201Cu;
			break;
		case 0x94:
			*out = 0x201Du;
			break;
		case 0x95:
			*out = 0x2022u;
			break;
		case 0x96:
			*out = 0x2013u;
			break;
		case 0x97:
			*out = 0x2014u;
			break;
		case 0x98:
			*out = 0x2DCu;
			break;
		case 0x99:
			*out = 0x2122u;
			break;
		case 0x9A:
			*out = 0x161u;
			break;
		case 0x9B:
			*out = 0x203Au;
			break;
		case 0x9C:
			*out = 0x153u;
			break;
		case 0x9E:
			*out = 0x17Eu;
			break;
		case 0x9F:
			*out = 0x178u;
			break;
		}
		if (chr == 0x0u) {break;}
	}
}