| 1 |
/* This file is part of GNU Dico. |
| 2 |
Copyright (C) 2012-2024 Sergey Poznyakoff |
| 3 |
|
| 4 |
GNU Dico is free software; you can redistribute it and/or modify |
| 5 |
it under the terms of the GNU General Public License as published by |
| 6 |
the Free Software Foundation; either version 3, or (at your option) |
| 7 |
any later version. |
| 8 |
|
| 9 |
GNU Dico is distributed in the hope that it will be useful, |
| 10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
GNU General Public License for more details. |
| 13 |
|
| 14 |
You should have received a copy of the GNU General Public License |
| 15 |
along with GNU Dico. If not, see <http://www.gnu.org/licenses/>. */ |
| 16 |
|
| 17 |
#include <config.h> |
| 18 |
#include <stdlib.h> |
| 19 |
#include <string.h> |
| 20 |
#include "gcide.h" |
| 21 |
|
| 22 |
struct gcide_entity { |
| 23 |
char *ent; |
| 24 |
char *text; |
| 25 |
}; |
| 26 |
|
| 27 |
static struct gcide_entity gcide_entity[] = { |
| 28 |
{ "Cced", "Ç" }, |
| 29 |
{ "uum", "ü" }, |
| 30 |
{ "eacute", "é" }, |
| 31 |
{ "acir", "â" }, |
| 32 |
{ "aum", "ä" }, |
| 33 |
{ "agrave", "à" }, |
| 34 |
{ "aring", "å" }, |
| 35 |
{ "ccedil", "ç" }, |
| 36 |
{ "cced", "ç" }, |
| 37 |
{ "ccar", "č" }, |
| 38 |
{ "cacute", "ć" }, |
| 39 |
{ "ecir", "ê" }, |
| 40 |
{ "eum", "ë" }, |
| 41 |
{ "egrave", "è" }, |
| 42 |
{ "ium", "ï" }, |
| 43 |
{ "icir", "î" }, |
| 44 |
{ "igrave", "ì" }, |
| 45 |
{ "Aum", "Ä" }, |
| 46 |
{ "Aring", "Å" }, |
| 47 |
{ "Eacute", "É" }, |
| 48 |
{ "ae", "æ" }, |
| 49 |
{ "AE", "Æ" }, |
| 50 |
{ "ocir", "ô" }, |
| 51 |
{ "oum", "ö" }, |
| 52 |
{ "ograve", "ò" }, |
| 53 |
{ "oacute", "ó" }, |
| 54 |
{ "Oacute", "Ó" }, |
| 55 |
{ "ucir", "û" }, |
| 56 |
{ "ugrave", "ù" }, |
| 57 |
{ "uacute", "ú" }, |
| 58 |
{ "yum", "ÿ" }, |
| 59 |
{ "Oum", "Ö" }, |
| 60 |
{ "Uum", "Ü" }, |
| 61 |
{ "pound", "£", }, |
| 62 |
{ "aacute", "á" }, |
| 63 |
{ "iacute", "í" }, |
| 64 |
{ "dele", "₰" }, /* FIXME: <dele/ is used to represent the Deleatur |
| 65 |
sign in the entry for "Dele". There is no |
| 66 |
corresponding symbol in Unicode, so the German |
| 67 |
pfennig sign is used instead. See |
| 68 |
https://www.unicode.org/L2/L2021/21230-delete-sign.pdf |
| 69 |
*/ |
| 70 |
|
| 71 |
/* Vulgar fractions */ |
| 72 |
{ "frac00", "0/0" }, /* FIXME */ |
| 73 |
{ "frac12", "½" }, |
| 74 |
{ "frac13", "⅓" }, |
| 75 |
{ "frac14", "¼" }, |
| 76 |
{ "frac15", "⅕" }, |
| 77 |
{ "frac16", "⅙" }, |
| 78 |
{ "frac17", "⅐" }, |
| 79 |
{ "frac18", "⅛" }, |
| 80 |
{ "frac19", "⅑" }, |
| 81 |
{ "frac23", "⅔" }, |
| 82 |
{ "frac25", "⅖" }, |
| 83 |
{ "frac32", "³⁄₂" }, |
| 84 |
{ "frac34", "¾" }, |
| 85 |
{ "frac35", "⅗" }, |
| 86 |
{ "frac36", "³⁄₆" }, |
| 87 |
{ "frac37", "³⁄₇" }, |
| 88 |
{ "frac38", "⅜" }, |
| 89 |
{ "frac43", "⁴⁄₃" }, |
| 90 |
{ "frac56", "⅚" }, |
| 91 |
{ "frac58", "⅝" }, |
| 92 |
{ "frac59", "⁵⁄₉" }, |
| 93 |
{ "frac67", "⁶⁄₇" }, |
| 94 |
{ "frac95", "⁹⁄₅" }, |
| 95 |
{ "frac1000x1434", "¹⁰⁰⁰⁄₁₄₃₄" }, |
| 96 |
{ "frac12x13", "¹²⁄₁₃" }, |
| 97 |
{ "frac17x175", "¹⁷⁄₁₇₅" }, |
| 98 |
{ "frac1x10", "⅒" }, |
| 99 |
{ "frac1x100", "¹⁄₁₀₀" }, |
| 100 |
{ "frac1x1000", "¹⁄₁₀₀₀" }, |
| 101 |
{ "frac1x10000", "¹⁄₁₀₀₀₀" }, |
| 102 |
{ "frac1x108719", "¹⁄₁₀₈₇₁₉" }, |
| 103 |
{ "frac1x12", "¹⁄₁₂" }, |
| 104 |
{ "frac1x20", "¹⁄₂₀" }, |
| 105 |
{ "frac1x216000", "¹⁄₂₁₆₀₀₀" }, |
| 106 |
{ "frac1x24", "¹⁄₂₄" }, |
| 107 |
{ "frac1x2500", "¹⁄₂₅₀₀" }, |
| 108 |
{ "frac1x29966", "¹⁄₂₉₉₆₆" }, |
| 109 |
{ "frac1x3600", "¹⁄₃₆₀₀" }, |
| 110 |
{ "frac1x50000", "¹⁄₅₀₀₀₀" }, |
| 111 |
{ "frac1x60", "¹⁄₆₀" }, |
| 112 |
{ "frac1x6000", "¹⁄₆₀₀₀" }, |
| 113 |
{ "frac1x6400", "¹⁄₆₄₀₀₀" }, |
| 114 |
{ "frac1x8000", "¹⁄₈₀₀₀" }, |
| 115 |
{ "frac25x100", "²⁵⁄₁₀₀" }, |
| 116 |
{ "frac2x10", "²⁄₁₀" }, |
| 117 |
{ "frac3x16", "³⁄₁₆" }, |
| 118 |
{ "frac925x1000", "⁹²⁵⁄₁₀₀₀" }, |
| 119 |
|
| 120 |
{ "?", "<?>" }, /* Place-holder for unknown or illegible character. */ |
| 121 |
{ "hand", "☞" }, /* pointing hand (printer's "fist") */ |
| 122 |
{ "nabla", "∇" }, |
| 123 |
{ "sect", "§" }, |
| 124 |
{ "amac", "ā" }, |
| 125 |
{ "nsm", "ṉ" }, /* "n sub-macron" */ |
| 126 |
{ "sharp", "♯" }, |
| 127 |
{ "flat", "♭" }, |
| 128 |
{ "th", "th" }, |
| 129 |
{ "imac", "ī" }, |
| 130 |
{ "emac", "ē" }, |
| 131 |
{ "csdot", "c̣" }, |
| 132 |
{ "dsdot", "ḍ" }, /* Sanskrit/Tamil d dot */ |
| 133 |
{ "hsdot", "ḥ" }, |
| 134 |
{ "lsdot", "ḷ" }, |
| 135 |
{ "msdot", "ṃ" }, |
| 136 |
{ "nsdot", "ṇ" }, /* Sanskrit/Tamil n dot */ |
| 137 |
{ "tsdot", "ṭ" }, /* Sanskrit/Tamil t dot */ |
| 138 |
{ "zsdot", "ẓ" }, |
| 139 |
{ "ecr", "ĕ" }, |
| 140 |
{ "icr", "ĭ" }, |
| 141 |
{ "ocr", "ŏ" }, |
| 142 |
{ "OE", "Œ" }, |
| 143 |
{ "oe", "œ" }, |
| 144 |
{ "omac", "ō" }, |
| 145 |
{ "Omac", "Ō" }, |
| 146 |
{ "oomac", "o͞o" }, |
| 147 |
{ "oocr", "o͝o" }, |
| 148 |
{ "umac", "ū" }, |
| 149 |
{ "ocar", "ǒ" }, |
| 150 |
{ "aemac", "ǣ" }, |
| 151 |
{ "ucr", "ŭ" }, |
| 152 |
{ "acr", "ă" }, |
| 153 |
{ "ycr", "y̆" }, |
| 154 |
{ "ymac", "ȳ" }, |
| 155 |
{ "asl", "ā́" }, /* a "semilong" */ |
| 156 |
{ "esl", "ḗ" }, /* e "semilong" */ |
| 157 |
{ "isl", "ī́" }, /* i "semilong" */ |
| 158 |
{ "osl", "ṓ" }, /* o "semilong" */ |
| 159 |
{ "usl", "ū́" }, /* u "semilong" */ |
| 160 |
{ "adot", "ȧ" }, /* a with dot above */ |
| 161 |
{ "edh", "ð" }, |
| 162 |
{ "EDH", "Ð" }, |
| 163 |
{ "thorn", "þ" }, |
| 164 |
{ "atil", "ã" }, |
| 165 |
{ "etil", "ẽ" }, |
| 166 |
{ "itil", "ĩ" }, |
| 167 |
{ "otil", "õ" }, |
| 168 |
{ "util", "ũ" }, |
| 169 |
{ "ntil", "ñ" }, |
| 170 |
{ "ncir", "ñ" }, |
| 171 |
{ "Atil", "Ã" }, |
| 172 |
{ "Etil", "Ẽ" }, |
| 173 |
{ "Itil", "Ĩ" }, |
| 174 |
{ "Otil", "Õ" }, |
| 175 |
{ "Util", "Ũ" }, |
| 176 |
{ "Ntil", "Ñ" }, |
| 177 |
{ "mdot", "ṁ" }, |
| 178 |
{ "ndot", "ṅ" }, |
| 179 |
{ "rsdot", "ṛ" }, |
| 180 |
{ "usdot", "ụ" }, |
| 181 |
{ "uring", "ů" }, |
| 182 |
{ "zdot", "ż" }, |
| 183 |
{ "yogh", "ȝ" }, |
| 184 |
{ "deg", "°" }, |
| 185 |
{ "min", "′" }, |
| 186 |
{ "sec", "˝" }, |
| 187 |
{ "middot", "•" }, |
| 188 |
{ "ounceap", "℥" }, |
| 189 |
{ "root", "√" }, |
| 190 |
{ "cuberoot", "∛" }, |
| 191 |
{ "asterism", "⁂" }, |
| 192 |
|
| 193 |
/* Music sheet notation */ |
| 194 |
{ "segno", "𝄋" }, /* Introduced recently in entries for Segno, Al |
| 195 |
segno, and Del segno. */ |
| 196 |
{ "pause", "𝄐" }, |
| 197 |
{ "natural", "♮" }, |
| 198 |
{ "upslur", "" }, |
| 199 |
{ "downslur", "" }, |
| 200 |
|
| 201 |
/* Greek alphabet */ |
| 202 |
{ "alpha", "α" }, |
| 203 |
{ "beta", "β" }, |
| 204 |
{ "gamma", "γ" }, |
| 205 |
{ "delta", "δ" }, |
| 206 |
{ "epsilon", "ε" }, |
| 207 |
{ "zeta", "ζ" }, |
| 208 |
{ "eta", "η" }, |
| 209 |
{ "theta", "θ" }, |
| 210 |
{ "iota", "ι" }, |
| 211 |
{ "kappa", "κ" }, |
| 212 |
{ "lambda", "λ" }, |
| 213 |
{ "mu", "μ" }, |
| 214 |
{ "nu", "ν" }, |
| 215 |
{ "xi", "ξ" }, |
| 216 |
{ "omicron", "ο" }, |
| 217 |
{ "pi", "π" }, |
| 218 |
{ "rho", "ρ" }, |
| 219 |
{ "sigma", "σ" }, |
| 220 |
{ "sigmat", "ς" }, |
| 221 |
{ "tau", "τ" }, |
| 222 |
{ "upsilon", "υ" }, |
| 223 |
{ "phi", "φ" }, |
| 224 |
{ "chi", "χ" }, |
| 225 |
{ "psi", "ψ" }, |
| 226 |
{ "omega", "ω" }, |
| 227 |
{ "digamma", "ϝ" }, |
| 228 |
{ "ALPHA", "Α" }, |
| 229 |
{ "BETA", "Β" }, |
| 230 |
{ "GAMMA", "Γ" }, |
| 231 |
{ "DELTA", "Δ" }, |
| 232 |
{ "EPSILON", "Ε" }, |
| 233 |
{ "ZETA", "Ζ" }, |
| 234 |
{ "ETA", "Η" }, |
| 235 |
{ "THETA", "Θ" }, |
| 236 |
{ "IOTA", "Ι" }, |
| 237 |
{ "KAPPA", "Κ" }, |
| 238 |
{ "LAMBDA", "Λ" }, |
| 239 |
{ "MU", "Μ" }, |
| 240 |
{ "NU", "Ν" }, |
| 241 |
{ "XI", "Ξ" }, |
| 242 |
{ "OMICRON", "Ο" }, |
| 243 |
{ "PI", "Π" }, |
| 244 |
{ "RHO", "Ρ" }, |
| 245 |
{ "SIGMA", "Σ" }, |
| 246 |
{ "TAU", "Τ" }, |
| 247 |
{ "UPSILON", "Υ" }, |
| 248 |
{ "PHI", "Φ" }, |
| 249 |
{ "CHI", "Χ" }, |
| 250 |
{ "PSI", "Ψ" }, |
| 251 |
{ "OMEGA", "Ω" }, |
| 252 |
/* Italic letters */ |
| 253 |
{ "AIT", "A" }, |
| 254 |
{ "BIT", "B" }, |
| 255 |
{ "CIT", "C" }, |
| 256 |
{ "DIT", "D" }, |
| 257 |
{ "EIT", "E" }, |
| 258 |
{ "FIT", "F" }, |
| 259 |
{ "GIT", "G" }, |
| 260 |
{ "HIT", "H" }, |
| 261 |
{ "IIT", "I" }, |
| 262 |
{ "JIT", "J" }, |
| 263 |
{ "KIT", "K" }, |
| 264 |
{ "LIT", "L" }, |
| 265 |
{ "MIT", "M" }, |
| 266 |
{ "NOT", "N" }, |
| 267 |
{ "OIT", "O" }, |
| 268 |
{ "PIT", "P" }, |
| 269 |
{ "QIT", "Q" }, |
| 270 |
{ "RIT", "R" }, |
| 271 |
{ "SIT", "S" }, |
| 272 |
{ "TIT", "T" }, |
| 273 |
{ "UIT", "U" }, |
| 274 |
{ "VIT", "V" }, |
| 275 |
{ "WIT", "W" }, |
| 276 |
{ "XIT", "X" }, |
| 277 |
{ "YIT", "Y" }, |
| 278 |
{ "ZIT", "Z" }, |
| 279 |
{ "ait", "a" }, |
| 280 |
{ "bit", "b" }, |
| 281 |
{ "cit", "c" }, |
| 282 |
{ "dit", "d" }, |
| 283 |
{ "eit", "e" }, |
| 284 |
{ "fit", "f" }, |
| 285 |
{ "git", "g" }, |
| 286 |
{ "hit", "h" }, |
| 287 |
{ "iit", "i" }, |
| 288 |
{ "jit", "j" }, |
| 289 |
{ "kit", "k" }, |
| 290 |
{ "lit", "l" }, |
| 291 |
{ "mit", "m" }, |
| 292 |
{ "not", "n" }, |
| 293 |
{ "oit", "o" }, |
| 294 |
{ "pit", "p" }, |
| 295 |
{ "qit", "q" }, |
| 296 |
{ "rit", "r" }, |
| 297 |
{ "sit", "s" }, |
| 298 |
{ "tit", "t" }, |
| 299 |
{ "uit", "u" }, |
| 300 |
{ "vit", "v" }, |
| 301 |
{ "wit", "w" }, |
| 302 |
{ "xit", "x" }, |
| 303 |
{ "yit", "y" }, |
| 304 |
{ "zit", "z" }, |
| 305 |
|
| 306 |
{ "add", "a̤" }, |
| 307 |
{ "udd", "ṳ" }, |
| 308 |
{ "ADD", "A̤" }, |
| 309 |
{ "UDD", "Ṳ" }, |
| 310 |
|
| 311 |
/* Diacritics and special symbols */ |
| 312 |
{ "cre", "⌣" }, |
| 313 |
{ "breve", "̆" }, |
| 314 |
{ "umlaut", "̈" }, |
| 315 |
{ "asper", "̔" }, |
| 316 |
{ "prime", "´" }, |
| 317 |
{ "Prime", "′" }, |
| 318 |
{ "bprime", "˝" }, |
| 319 |
{ "mdash", "—" }, |
| 320 |
{ "divide", "÷" }, |
| 321 |
{ "times", "×" }, |
| 322 |
|
| 323 |
/* Quotes */ |
| 324 |
{ "lsquo", "‘" }, |
| 325 |
{ "ldquo", "“" }, |
| 326 |
{ "rdquo", "”" }, |
| 327 |
|
| 328 |
{ "dagger", "†" }, |
| 329 |
{ "dag", "†" }, |
| 330 |
{ "Dagger", "‡" }, |
| 331 |
{ "ddag", "‡" }, |
| 332 |
{ "para", "§" }, |
| 333 |
{ "gt", ">" }, |
| 334 |
{ "lt", "<" }, |
| 335 |
{ "rarr", "→" }, |
| 336 |
{ "larr", "←" }, |
| 337 |
{ "schwa", "ə" }, |
| 338 |
|
| 339 |
/* { "br", "\n" }, This is handled explicitly by the scanner. */ |
| 340 |
{ "and", "and" }, |
| 341 |
{ "or", "or" }, |
| 342 |
|
| 343 |
{ "iques", "¿" }, |
| 344 |
{ "integral2l", "∫" }, |
| 345 |
|
| 346 |
{ "Aries", "♈" }, |
| 347 |
{ "Taurus", "♉" }, |
| 348 |
{ "Gemini", "♊" }, |
| 349 |
{ "Cancer", "♋" }, |
| 350 |
{ "Leo", "♌" }, |
| 351 |
{ "Virgo", "♍" }, |
| 352 |
{ "Libra", "♎" }, |
| 353 |
{ "Scorpio", "♏" }, |
| 354 |
{ "Sagittarius", "♐" }, |
| 355 |
{ "Capricorn", "♑" }, |
| 356 |
{ "Aquarius", "♒" }, |
| 357 |
{ "Pisces", "♓" }, |
| 358 |
|
| 359 |
{ "Sun", "☉" }, |
| 360 |
{ "Mercury", "☿" }, |
| 361 |
{ "Venus", "♀" }, |
| 362 |
{ "Mars", "♂" }, |
| 363 |
{ "Jupiter", "♃" }, |
| 364 |
{ "Uranus", "♅" }, |
| 365 |
{ "Neptune", "♆" }, |
| 366 |
{ "Ceres", "⚳" }, |
| 367 |
{ "Chiron", "⚷" }, |
| 368 |
|
| 369 |
{ "astascending", "☊" }, |
| 370 |
{ "astdescending", "☋" }, |
| 371 |
|
| 372 |
/* See CIDE.M, Mars, 3 */ |
| 373 |
{ "Male", "♂" }, |
| 374 |
|
| 375 |
/* Roman numerals */ |
| 376 |
{ "Crev", "Ↄ" }, |
| 377 |
|
| 378 |
|
| 379 |
{ "filig", "fi" }, |
| 380 |
{ "fllig", "fl" }, |
| 381 |
{ "fflig", "ff" }, |
| 382 |
{ "ffllig", "ffl" }, |
| 383 |
|
| 384 |
/* In pronunciacions: */ |
| 385 |
{ "ai", "ɑː" }, |
| 386 |
|
| 387 |
{ NULL } |
| 388 |
}; |
| 389 |
|
| 390 |
char const * |
| 391 |
gcide_entity_to_utf8(const char *str) |
| 392 |
{ |
| 393 |
struct gcide_entity *p; |
| 394 |
size_t len; |
| 395 |
|
| 396 |
if (str[0] == '<') { |
| 397 |
str++; |
| 398 |
len = strcspn(str, "/"); |
| 399 |
} else |
| 400 |
len = strlen(str); |
| 401 |
|
| 402 |
for (p = gcide_entity; p->ent; p++) { |
| 403 |
if (p->ent[0] == str[0] && strlen(p->ent) == len && memcmp(p->ent, str, len) == 0) |
| 404 |
return p->text; |
| 405 |
} |
| 406 |
return NULL; |
| 407 |
} |