File: ent.c

package info (click to toggle)
dico 2.12-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 21,300 kB
  • sloc: ansic: 94,671; sh: 52,520; lex: 4,023; tcl: 1,439; yacc: 1,439; makefile: 1,387; python: 1,310; perl: 1,200; lisp: 489; awk: 157; pascal: 127; javascript: 71; cpp: 50; fortran: 28; asm: 21; sed: 16; xml: 8
file content (407 lines) | stat: -rw-r--r-- 11,033 bytes parent folder | download | duplicates (2)
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
/* This file is part of GNU Dico.
   Copyright (C) 2012-2024 Sergey Poznyakoff

   GNU Dico is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3, or (at your option)
   any later version.

   GNU Dico is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with GNU Dico.  If not, see <http://www.gnu.org/licenses/>. */

#include <config.h>
#include <stdlib.h>
#include <string.h>
#include "gcide.h"

struct gcide_entity {
    char *ent;
    char *text;
};

static struct gcide_entity gcide_entity[] = {
    { "Cced",   "Ç" },
    { "uum",    "ü" },
    { "eacute", "é" },
    { "acir",   "â" },
    { "aum",    "ä" },
    { "agrave", "à" },
    { "aring",  "å" },
    { "ccedil", "ç" },
    { "cced",   "ç" },
    { "ccar",   "č" },
    { "cacute", "ć" },
    { "ecir",   "ê" },
    { "eum",    "ë" },
    { "egrave", "è" },
    { "ium",    "ï" },
    { "icir",   "î" },
    { "igrave", "ì" },
    { "Aum",    "Ä" },
    { "Aring",  "Å" },
    { "Eacute", "É" },
    { "ae",     "æ" },
    { "AE",     "Æ" },
    { "ocir",   "ô" },
    { "oum",    "ö" },
    { "ograve", "ò" },
    { "oacute", "ó" },
    { "Oacute", "Ó" },
    { "ucir",   "û" },
    { "ugrave", "ù" },
    { "uacute", "ú" },
    { "yum",    "ÿ" },
    { "Oum",    "Ö" },
    { "Uum",    "Ü" },
    { "pound",  "£", },
    { "aacute", "á" },
    { "iacute", "í" },
    { "dele",   "₰" }, /* FIXME: <dele/ is used to represent the Deleatur
			  sign in the entry for "Dele". There is no
			  corresponding symbol in Unicode, so the German
			  pfennig sign is used instead.  See
			  https://www.unicode.org/L2/L2021/21230-delete-sign.pdf
		       */

    /* Vulgar fractions */
    { "frac00",        "0/0" }, /* FIXME */
    { "frac12", "½" },
    { "frac13", "⅓" },
    { "frac14", "¼" },
    { "frac15", "⅕" },
    { "frac16", "⅙" },
    { "frac17", "⅐" },
    { "frac18", "⅛" },
    { "frac19", "⅑" },
    { "frac23", "⅔" },
    { "frac25", "⅖" },
    { "frac32", "³⁄₂" },
    { "frac34", "¾" },
    { "frac35", "⅗" },
    { "frac36", "³⁄₆" },
    { "frac37", "³⁄₇" },
    { "frac38", "⅜" },
    { "frac43", "⁴⁄₃" },
    { "frac56", "⅚" },
    { "frac58", "⅝" },
    { "frac59", "⁵⁄₉" },
    { "frac67", "⁶⁄₇" },
    { "frac95", "⁹⁄₅" },
    { "frac1000x1434", "¹⁰⁰⁰⁄₁₄₃₄" },
    { "frac12x13",  "¹²⁄₁₃" },
    { "frac17x175", "¹⁷⁄₁₇₅" },
    { "frac1x10",   "⅒" },
    { "frac1x100",  "¹⁄₁₀₀" },
    { "frac1x1000", "¹⁄₁₀₀₀" },
    { "frac1x10000", "¹⁄₁₀₀₀₀" },
    { "frac1x108719", "¹⁄₁₀₈₇₁₉" },
    { "frac1x12",      "¹⁄₁₂" },
    { "frac1x20",   "¹⁄₂₀" },
    { "frac1x216000", "¹⁄₂₁₆₀₀₀" },
    { "frac1x24",   "¹⁄₂₄" },
    { "frac1x2500", "¹⁄₂₅₀₀" },
    { "frac1x29966", "¹⁄₂₉₉₆₆" },
    { "frac1x3600", "¹⁄₃₆₀₀" },
    { "frac1x50000", "¹⁄₅₀₀₀₀" },
    { "frac1x60",   "¹⁄₆₀" },
    { "frac1x6000", "¹⁄₆₀₀₀" },
    { "frac1x6400",  "¹⁄₆₄₀₀₀" },
    { "frac1x8000", "¹⁄₈₀₀₀" },
    { "frac25x100", "²⁵⁄₁₀₀" },
    { "frac2x10",   "²⁄₁₀" },
    { "frac3x16",   "³⁄₁₆" },
    { "frac925x1000", "⁹²⁵⁄₁₀₀₀" },

    { "?",      "<?>" }, /* Place-holder for unknown or illegible character. */
    { "hand",   "☞" },   /* pointing hand (printer's "fist") */
    { "nabla",  "∇" },
    { "sect",   "§" },
    { "amac",   "ā" },
    { "nsm",    "ṉ" },   /* "n sub-macron" */
    { "sharp",  "♯" },
    { "flat",   "♭" },
    { "th",     "th" },
    { "imac",   "ī" },
    { "emac",   "ē" },
    { "csdot",  "c̣"  },
    { "dsdot",  "ḍ" },   /* Sanskrit/Tamil d dot */
    { "hsdot",  "ḥ" },
    { "lsdot",  "ḷ" },
    { "msdot",  "ṃ" },
    { "nsdot",  "ṇ" },   /* Sanskrit/Tamil n dot */
    { "tsdot",  "ṭ" },   /* Sanskrit/Tamil t dot */
    { "zsdot",  "ẓ" },
    { "ecr",    "ĕ" },
    { "icr",    "ĭ" },
    { "ocr",    "ŏ" },
    { "OE",     "Œ" },
    { "oe",     "œ" },
    { "omac",   "ō" },
    { "Omac",   "Ō" },
    { "oomac",  "o͞o" },
    { "oocr",   "o͝o" },
    { "umac",   "ū" },
    { "ocar",   "ǒ" },
    { "aemac",  "ǣ" },
    { "ucr",    "ŭ" },
    { "acr",    "ă" },
    { "ycr",    "y̆" },
    { "ymac",   "ȳ" },
    { "asl",    "ā́" },   /* a "semilong" */
    { "esl",    "ḗ" },   /* e "semilong" */
    { "isl",    "ī́" },   /* i "semilong" */
    { "osl",    "ṓ" },   /* o "semilong" */
    { "usl",    "ū́" },   /* u "semilong" */
    { "adot",   "ȧ" },   /* a with dot above */
    { "edh",    "ð" },
    { "EDH",    "Ð" },
    { "thorn",  "þ" },
    { "atil",   "ã" },
    { "etil",   "ẽ" },
    { "itil",   "ĩ" },
    { "otil",   "õ" },
    { "util",   "ũ" },
    { "ntil",   "ñ" },
    { "ncir",   "ñ" },
    { "Atil",   "Ã" },
    { "Etil",   "Ẽ" },
    { "Itil",   "Ĩ" },
    { "Otil",   "Õ" },
    { "Util",   "Ũ" },
    { "Ntil",   "Ñ" },
    { "mdot",   "ṁ" },
    { "ndot",   "ṅ" },
    { "rsdot",  "ṛ" },
    { "usdot",  "ụ" },
    { "uring",  "ů" },
    { "zdot",   "ż" },
    { "yogh",   "ȝ" },
    { "deg",    "°" },
    { "min",    "′" },
    { "sec",    "˝" },
    { "middot", "•" },
    { "ounceap", "℥" },
    { "root",   "√" },
    { "cuberoot", "∛" },
    { "asterism", "⁂" },

    /* Music sheet notation */
    { "segno",  "𝄋" }, /* Introduced recently in entries for Segno, Al
			     segno, and Del segno. */
    { "pause",   "𝄐" },
    { "natural", "♮" },
    { "upslur",   "𝅷" },
    { "downslur", "𝅸" },

    /* Greek alphabet */
    { "alpha",    "α" },
    { "beta",     "β" },
    { "gamma",    "γ" },
    { "delta",    "δ" },
    { "epsilon",  "ε" },
    { "zeta",     "ζ" },
    { "eta",      "η" },
    { "theta",    "θ" },
    { "iota",     "ι" },
    { "kappa",    "κ" },
    { "lambda",   "λ" },
    { "mu",       "μ" },
    { "nu",       "ν" },
    { "xi",       "ξ" },
    { "omicron",  "ο" },
    { "pi",       "π" },
    { "rho",      "ρ" },
    { "sigma",    "σ" },
    { "sigmat",   "ς" },
    { "tau",      "τ" },
    { "upsilon",  "υ" },
    { "phi",      "φ" },
    { "chi",      "χ" },
    { "psi",      "ψ" },
    { "omega",    "ω" },
    { "digamma",  "ϝ" },
    { "ALPHA",    "Α" },
    { "BETA",     "Β" },
    { "GAMMA",    "Γ" },
    { "DELTA",    "Δ" },
    { "EPSILON",  "Ε" },
    { "ZETA",     "Ζ" },
    { "ETA",      "Η" },
    { "THETA",    "Θ" },
    { "IOTA",     "Ι" },
    { "KAPPA",    "Κ" },
    { "LAMBDA",   "Λ" },
    { "MU",       "Μ" },
    { "NU",       "Ν" },
    { "XI",       "Ξ" },
    { "OMICRON",  "Ο" },
    { "PI",       "Π" },
    { "RHO",      "Ρ" },
    { "SIGMA",    "Σ" },
    { "TAU",      "Τ" },
    { "UPSILON",  "Υ" },
    { "PHI",      "Φ" },
    { "CHI",      "Χ" },
    { "PSI",      "Ψ" },
    { "OMEGA",    "Ω" },
    /* Italic letters */
    { "AIT",      "A" },
    { "BIT",      "B" },
    { "CIT",      "C" },
    { "DIT",      "D" },
    { "EIT",      "E" },
    { "FIT",      "F" },
    { "GIT",      "G" },
    { "HIT",      "H" },
    { "IIT",      "I" },
    { "JIT",      "J" },
    { "KIT",      "K" },
    { "LIT",      "L" },
    { "MIT",      "M" },
    { "NOT",      "N" },
    { "OIT",      "O" },
    { "PIT",      "P" },
    { "QIT",      "Q" },
    { "RIT",      "R" },
    { "SIT",      "S" },
    { "TIT",      "T" },
    { "UIT",      "U" },
    { "VIT",      "V" },
    { "WIT",      "W" },
    { "XIT",      "X" },
    { "YIT",      "Y" },
    { "ZIT",      "Z" },
    { "ait",      "a" },
    { "bit",      "b" },
    { "cit",      "c" },
    { "dit",      "d" },
    { "eit",      "e" },
    { "fit",      "f" },
    { "git",      "g" },
    { "hit",      "h" },
    { "iit",      "i" },
    { "jit",      "j" },
    { "kit",      "k" },
    { "lit",      "l" },
    { "mit",      "m" },
    { "not",      "n" },
    { "oit",      "o" },
    { "pit",      "p" },
    { "qit",      "q" },
    { "rit",      "r" },
    { "sit",      "s" },
    { "tit",      "t" },
    { "uit",      "u" },
    { "vit",      "v" },
    { "wit",      "w" },
    { "xit",      "x" },
    { "yit",      "y" },
    { "zit",      "z" },

    { "add",      "a̤" },
    { "udd",      "ṳ" },
    { "ADD",      "A̤" },
    { "UDD",      "Ṳ" },

    /* Diacritics and special symbols */
    { "cre",      "⌣" },
    { "breve",    "̆" },
    { "umlaut",   "̈" },
    { "asper",    "̔" },
    { "prime",    "´" },
    { "Prime",    "′" },
    { "bprime",   "˝" },
    { "mdash",    "—" },
    { "divide",   "÷" },
    { "times",    "×" },

    /* Quotes */
    { "lsquo",    "‘" },
    { "ldquo",    "“" },
    { "rdquo",    "”" },

    { "dagger",   "†" },
    { "dag",      "†" },
    { "Dagger",   "‡" },
    { "ddag",     "‡" },
    { "para",     "§" },
    { "gt",       ">" },
    { "lt",       "<" },
    { "rarr",     "→" },
    { "larr",     "←" },
    { "schwa",    "ə" },

/*  { "br",       "\n" },  This is handled explicitly by the scanner. */
    { "and",      "and" },
    { "or",       "or" },

    { "iques",    "¿" },
    { "integral2l", "∫" },

    { "Aries",       "♈" },
    { "Taurus",      "♉" },
    { "Gemini",      "♊" },
    { "Cancer",      "♋" },
    { "Leo",         "♌" },
    { "Virgo",       "♍" },
    { "Libra",       "♎" },
    { "Scorpio",     "♏" },
    { "Sagittarius", "♐" },
    { "Capricorn",   "♑" },
    { "Aquarius",    "♒" },
    { "Pisces",      "♓" },

    { "Sun",         "☉" },
    { "Mercury",     "☿" },
    { "Venus",       "♀" },
    { "Mars",        "♂" },
    { "Jupiter",     "♃" },
    { "Uranus",      "♅" },
    { "Neptune",     "♆" },
    { "Ceres",       "⚳" },
    { "Chiron",      "⚷" },

    { "astascending",  "☊" },
    { "astdescending", "☋" },

    /* See CIDE.M, Mars, 3 */
    { "Male",        "♂" },

    /* Roman numerals */
    { "Crev",  "Ↄ" },


    { "filig", "fi" },
    { "fllig", "fl" },
    { "fflig", "ff" },
    { "ffllig", "ffl" },

    /* In pronunciacions: */
    { "ai",    "ɑː" },

    { NULL }
};

char const *
gcide_entity_to_utf8(const char *str)
{
    struct gcide_entity *p;
    size_t len;

    if (str[0] == '<') {
	str++;
	len = strcspn(str, "/");
    } else
	len = strlen(str);

    for (p = gcide_entity; p->ent; p++) {
	if (p->ent[0] == str[0] && strlen(p->ent) == len && memcmp(p->ent, str, len) == 0)
	    return p->text;
    }
    return NULL;
}