blob: 147ddafb588b28f3f92739d3ce1c0d8df86ecafe (
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
112
113
|
/*
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_win1252enc(zap_chr20 const * const _in,zap_chr8 * const _out) {
zap_chr20 const * in = _in;
zap_chr8 * out = _out;
for (;;++in,++out) {
zap_chr20 const chr = *in;
zap_chr8 const bad = 0x3Fu;
switch (chr) {
default:
sus_unlikely (chr > 0xFFu) {
*out = bad;
break;
}
sus_unlikely (chr >= 0x80u && chr <= 0x9Fu) {
*out = bad;
break;
}
*out = *in;
break;
case 0x20ACu:
*out = 0x80u;
break;
case 0x201Au:
*out = 0x82u;
break;
case 0x192u:
*out = 0x83u;
break;
case 0x201Eu:
*out = 0x84u;
break;
case 0x2026u:
*out = 0x85u;
break;
case 0x2020u:
*out = 0x86u;
break;
case 0x2021u:
*out = 0x87u;
break;
case 0x2C6u:
*out = 0x88u;
break;
case 0x2030u:
*out = 0x89u;
break;
case 0x160u:
*out = 0x8Au;
break;
case 0x2039u:
*out = 0x8Bu;
break;
case 0x152u:
*out = 0x8Cu;
break;
case 0x17Du:
*out = 0x8Eu;
break;
case 0x2018u:
*out = 0x91u;
break;
case 0x2019u:
*out = 0x92u;
break;
case 0x201Cu:
*out = 0x93u;
break;
case 0x201Du:
*out = 0x94u;
break;
case 0x2022u:
*out = 0x95u;
break;
case 0x2013u:
*out = 0x96u;
break;
case 0x2014u:
*out = 0x97u;
break;
case 0x2DCu:
*out = 0x98u;
break;
case 0x2122u:
*out = 0x99u;
break;
case 0x161u:
*out = 0x9Au;
break;
case 0x203Au:
*out = 0x9Bu;
break;
case 0x153u:
*out = 0x9Cu;
break;
case 0x17Eu:
*out = 0x9Eu;
break;
case 0x178u:
*out = 0x9Fu;
break;
}
sus_unlikely (chr == 0x0u) {break;}
}
}
|