summaryrefslogtreecommitdiff
path: root/zap/source/any/str/win1252dec.c
blob: 0e29a5affd8d4cd0eeb56a6cf3798aa68f162e23 (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
/*
	Copyright 2022-2023 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/str.h>

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