-
Notifications
You must be signed in to change notification settings - Fork 1
/
cp437.c
228 lines (224 loc) · 10.3 KB
/
cp437.c
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
/*
* Copyright (C) 2010 Luigi Rizzo, Universita' di Pisa
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* $Id: cp437.c 7989 2010-12-06 13:47:53Z luigi $
*
* code to map cp437 into html entities
*/
#include "myts.h"
#include <ctype.h>
#include <stdlib.h> /* strtol */
static char cp437[] = " \n\
0x00 0x0000   NULL\n\
0x01 0x263A ☺ While Smiling Face\n\
0x02 0x263B ☻ Black Smiling Face\n\
0x03 0x2665 ♥ Black Heart Suit\n\
0x04 0x2666 ♦ Black Diamond Suit\n\
0x05 0x2663 ♣ Black Club Suit\n\
0x06 0x2660 ♠ Black Spades Suit\n\
0x07 0x2022 • Bullet\n\
0x08 0x25D8 ◘ Inverse Bullet\n\
0x09 0x25CB ○ White Circle\n\
0x0A 0x25D9 ◙ Inverse White Circle\n\
0x0B 0x2642 ♂ Male Sign\n\
0x0C 0x2640 ♀ Female Sign\n\
0x0D 0x266A ♪ Eighth Note\n\
0x0E 0x266B ♫ Beamed Eighth Note\n\
0x0F 0x263C ☼ White Sun With Rays\n\
0x10 0x25BA ► Black Right-Pointing Pointer\n\
0x11 0x25C4 ◄ Black Left-Pointing Pointer\n\
0x12 0x2195 ↕ Up Down Arrow\n\
0x13 0x203C ‼ Double Exclamation Mark\n\
0x14 0x00B6 ¶ Pilcrow Sign\n\
0x15 0x00A7 § Section Sign\n\
0x16 0x25AC ▬ Black Rectangle\n\
0x17 0x21A8 ↨ Up Down Arrow With Base\n\
0x18 0x2191 ↑ Upwards Arrow\n\
0x19 0x2193 ↓ Downwards Arrow\n\
0x1A 0x2192 → Rightwards Arrow\n\
0x1B 0x2190 ← Leftwards Arrow\n\
0x1C 0x221F ∟ Right Angle\n\
0x1D 0x2194 ↔ Left Right Arrow\n\
0x1E 0x25B2 ▲ Black Up-Pointing Triangle\n\
0x1F 0x25BC ▼ Black Down-Pointing Triangle\n\
0x7F 0x2302 ⌂ House\n\
0x80 0x00C7 Ç Latin Capital Letter C With Cedilla\n\
0x81 0x00FC ü Latin Small Letter U With Diaeresis\n\
0x82 0x00E9 é Latin Small Letter E With Acute\n\
0x83 0x00E2 â Latin Small Letter A With Circumflex\n\
0x84 0x00E4 ä Latin Small Letter A With Diaeresis\n\
0x85 0x00E0 à Latin Small Letter A With Grave\n\
0x86 0x00E5 å Latin Small Letter A With Ring Above\n\
0x87 0x00E7 ç Latin Small Letter C With Cedilla\n\
0x88 0x00EA ê Latin Small Letter E With Circumflex\n\
0x89 0x00EB ë Latin Small Letter E With Diaeresis\n\
0x8A 0x00E8 è Latin Small Letter E With Grave\n\
0x8B 0x00EF ï Latin Small Letter I With Diaeresis\n\
0x8C 0x00EE î Latin Small Letter I With Circumflex\n\
0x8D 0x00EC ì Latin Small Letter I With Grave\n\
0x8E 0x00C4 Ä Latin Capital Letter A With Diaeresis\n\
0x8F 0x00C5 Å Latin Capital Letter A With Ring Above\n\
0x90 0x00C9 É Latin Capital Letter E With Acute\n\
0x91 0x00E6 æ Latin Small Ligature Ae\n\
0x92 0x00C6 Æ Latin Capital Ligature Ae\n\
0x93 0x00F4 ô Latin Small Letter O With Circumflex\n\
0x94 0x00F6 ö Latin Small Letter O With Diaeresis\n\
0x95 0x00F2 ò Latin Small Letter O With Grave\n\
0x96 0x00FB û Latin Small Letter U With Circumflex\n\
0x97 0x00F9 ù Latin Small Letter U With Grave\n\
0x98 0x00FF ÿ Latin Small Letter Y With Diaeresis\n\
0x99 0x00D6 Ö Latin Capital Letter O With Diaeresis\n\
0x9A 0x00DC Ü Latin Capital Letter U With Diaeresis\n\
0x9B 0x00A2 ¢ Cent Sign\n\
0x9C 0x00A3 £ Pound Sign\n\
0x9D 0x00A5 ¥ Yen Sign\n\
0x9E 0x20A7 ₧ Peseta Sign\n\
0x9F 0x0192 ƒ Latin Small Letter F With Hook\n\
0xA0 0x00E1 á Latin Small Letter A With Acute\n\
0xA1 0x00ED í Latin Small Letter I With Acute\n\
0xA2 0x00F3 ó Latin Small Letter O With Acute\n\
0xA3 0x00FA ú Latin Small Letter U With Acute\n\
0xA4 0x00F1 ñ Latin Small Letter N With Tilde\n\
0xA5 0x00D1 Ñ Latin Capital Letter N With Tilde\n\
0xA6 0x00AA ª Feminine Ordinal Indicator\n\
0xA7 0x00BA º Masculine Ordinal Indicator\n\
0xA8 0x00BF ¿ Inverted Question Mark\n\
0xA9 0x2310 ⌐ Reversed Not Sign\n\
0xAA 0x00AC ¬ Not Sign\n\
0xAB 0x00BD ½ Vulgar Fraction One Half\n\
0xAC 0x00BC ¼ Vulgar Fraction One Quarter\n\
0xAD 0x00A1 ¡ Inverted Exclamation Mark\n\
0xAE 0x00AB « Left-Pointing Double Angle Quotation Mark\n\
0xAF 0x00BB » Right-Pointing Double Angle Quotation Mark\n\
0xB0 0x2591 ░ Light Shade\n\
0xB1 0x2592 ▒ Medium Shade\n\
0xB2 0x2593 ▓ Dark Shade\n\
0xB3 0x2502 │ Box Drawings Light Vertical\n\
0xB4 0x2524 ┤ Box Drawings Light Vertical And Left\n\
0xB5 0x2561 ╡ Box Drawings Vertical Single And Left Double\n\
0xB6 0x2562 ╢ Box Drawings Vertical Double And Left Single\n\
0xB7 0x2556 ╖ Box Drawings Down Double And Left Single\n\
0xB8 0x2555 ╕ Box Drawings Down Single And Left Double\n\
0xB9 0x2563 ╣ Box Drawings Double Vertical And Left\n\
0xBA 0x2551 ║ Box Drawings Double Vertical\n\
0xBB 0x2557 ╗ Box Drawings Double Down And Left\n\
0xBC 0x255D ╝ Box Drawings Double Up And Left\n\
0xBD 0x255C ╜ Box Drawings Up Double And Left Single\n\
0xBE 0x255B ╛ Box Drawings Up Single And Left Double\n\
0xBF 0x2510 ┐ Box Drawings Light Down And Left\n\
0xC0 0x2514 └ Box Drawings Light Up And Right\n\
0xC1 0x2534 ┴ Box Drawings Light Up And Horizontal\n\
0xC2 0x252C ┬ Box Drawings Light Down And Horizontal\n\
0xC3 0x251C ├ Box Drawings Light Vertical And Right\n\
0xC4 0x2500 ─ Box Drawings Light Horizontal\n\
0xC5 0x253C ┼ Box Drawings Light Vertical And Horizontal\n\
0xC6 0x255E ╞ Box Drawings Vertical Single And Right Double\n\
0xC7 0x255F ╟ Box Drawings Vertical Double And Right Single\n\
0xC8 0x255A ╚ Box Drawings Double Up And Right\n\
0xC9 0x2554 ╔ Box Drawings Double Down And Right\n\
0xCA 0x2569 ╩ Box Drawings Double Up And Horizontal\n\
0xCB 0x2566 ╦ Box Drawings Double Down And Horizontal\n\
0xCC 0x2560 ╠ Box Drawings Double Vertical And Right\n\
0xCD 0x2550 ═ Box Drawings Double Horizontal\n\
0xCE 0x256C ╬ Box Drawings Double Vertical And Horizontal\n\
0xCF 0x2567 ╧ Box Drawings Up Single And Horizontal Double\n\
0xD0 0x2568 ╨ Box Drawings Up Double And Horizontal Single\n\
0xD1 0x2564 ╤ Box Drawings Down Single And Horizontal Double\n\
0xD2 0x2565 ╥ Box Drawings Down Double And Horizontal Single\n\
0xD3 0x2559 ╙ Box Drawings Up Double And Right Single\n\
0xD4 0x2558 ╘ Box Drawings Up Single And Right Double\n\
0xD5 0x2552 ╒ Box Drawings Down Single And Right Double\n\
0xD6 0x2553 ╓ Box Drawings Down Double And Right Single\n\
0xD7 0x256B ╫ Box Drawings Vertical Double And Horizontal Single\n\
0xD8 0x256A ╪ Box Drawings Vertical Single And Horizontal Double\n\
0xD9 0x2518 ┘ Box Drawings Light Up And Left\n\
0xDA 0x250C ┌ Box Drawings Light Down And Right\n\
0xDB 0x2588 █ Full Block\n\
0xDC 0x2584 ▄ Lower Half Block\n\
0xDD 0x258C ▌ Left Half Block\n\
0xDE 0x2590 ▐ Right Half Block\n\
0xDF 0x2580 ▀ Upper Half Block\n\
0xE0 0x03B1 α Greek Small Letter Alpha\n\
0xE1 0x00DF ß Greek Capital Letter Beta / Latin Small Letter Esset\n\
0xE2 0x0393 Γ Greek Capital Letter Gamma\n\
0xE3 0x03C0 π Greek Small Letter Pi\n\
0xE4 0x03A3 Σ Greek Capital Letter Sigma\n\
0xE5 0x03C3 σ Greek Small Letter Sigma\n\
0xE6 0x00B5 µ Greek Small Letter Mu\n\
0xE7 0x03C4 τ Greek Small Letter Tau\n\
0xE8 0x03A6 Φ Greek Capital Letter Phi\n\
0xE9 0x0398 Θ Greek Capital Letter Theta\n\
0xEA 0x03A9 Ω Greek Capital Letter Omega\n\
0xEB 0x03B4 δ Greek Small Letter Delta\n\
0xEC 0x221E ∞ Infinity\n\
0xED 0x03C6 φ Greek Small Letter Phi\n\
0xEE 0x03B5 ε Greek Small Letter Epsilon\n\
0xEF 0x2229 ∩ Intersection\n\
0xF0 0x2261 ≡ Identical To\n\
0xF1 0x00B1 ± Plus-Minus Sign\n\
0xF2 0x2265 ≥ Greater-Than Or Equal To\n\
0xF3 0x2264 ≤ Less-Than Or Equal To\n\
0xF4 0x2320 ⌠ Top Half Integral\n\
0xF5 0x2321 ⌡ Bottom Half Integral\n\
0xF6 0x00F7 ÷ Division Sign\n\
0xF7 0x2248 ≈ Almost Equal To\n\
0xF8 0x00B0 ° Degree Sign\n\
0xF9 0x2219 ∙ Bullet Operator\n\
0xFA 0x00B7 · Middle Dot\n\
0xFB 0x221A √ Square Root\n\
0xFC 0x207F ⁿ Superscript Latin Small Letter N\n\
0xFD 0x00B2 ² Superscript Two\n\
0xFE 0x25A0 ■ Black Square\n\
0xFF 0x00A0   No-Break Space\n\
";
#include <stdio.h>
#include <string.h>
char *map437[256];
int build_map437(int argc, char *argv[])
{
char *a, *b = cp437;
DBG(2, "cp437 is %s\n", b);
while ( (a = strsep(&b, "\n")) ) {
int i = 0;
char *v[3];
v[0] = v[1] = v[2] = "-none-";
for (i=0; a && i < 3;) {
char *c = strsep(&a, " \t");
if (!c)
break;
if (!c[0] || (i == 2 && c[0] != '&'))
continue;
v[i++] = c;
}
i = strtol(v[0], NULL, 0);
if (isalnum(i) || i == 32)
v[2] = NULL;
map437[i] = v[2];
DBG(2, "fields %s %s\n", v[0], v[2] ? v[2] : "same");
}
map437[8] = map437[9] = map437[10] = map437[13] =
map437[27] = map437[127] = NULL;
return 0;
}