1 /* $NetBSD: lang.c,v 1.4 2025/12/31 22:18:50 oster Exp $ */ 2 3 /* lang.c -- language-dependent support. 4 Id: lang.c,v 1.14 2004/11/22 23:57:33 karl Exp 5 6 Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 Free Software 7 Foundation, Inc. 8 9 This program is free software; you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by 11 the Free Software Foundation; either version 2, or (at your option) 12 any later version. 13 14 This program is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with this program; if not, write to the Free Software 21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 22 23 Originally written by Karl Heinz Marbaise <kama (at) hippo.fido.de>. */ 24 25 #include "system.h" 26 #include "cmds.h" 27 #include "files.h" 28 #include "lang.h" 29 #include "makeinfo.h" 30 #include "xml.h" 31 32 /* Current document encoding. */ 33 encoding_code_type document_encoding_code = no_encoding; 34 35 /* Current language code; default is English. */ 36 language_code_type language_code = en; 37 38 /* By default, unsupported encoding is an empty string. */ 39 char *unknown_encoding = NULL; 40 41 static iso_map_type us_ascii_map [] = {{NULL, 0, 0}}; /* ASCII map is trivial */ 42 43 /* Translation table between HTML and ISO Codes. The last item is 44 hopefully the Unicode. It might be possible that those Unicodes are 45 not correct, cause I didn't check them. kama */ 46 static iso_map_type iso8859_1_map [] = { 47 { "nbsp", 0xA0, 0x00A0 }, 48 { "iexcl", 0xA1, 0x00A1 }, 49 { "cent", 0xA2, 0x00A2 }, 50 { "pound", 0xA3, 0x00A3 }, 51 { "curren", 0xA4, 0x00A4 }, 52 { "yen", 0xA5, 0x00A5 }, 53 { "brkbar", 0xA6, 0x00A6 }, 54 { "sect", 0xA7, 0x00A7 }, 55 { "uml", 0xA8, 0x00A8 }, 56 { "copy", 0xA9, 0x00A9 }, 57 { "ordf", 0xAA, 0x00AA }, 58 { "laquo", 0xAB, 0x00AB }, 59 { "not", 0xAC, 0x00AC }, 60 { "shy", 0xAD, 0x00AD }, 61 { "reg", 0xAE, 0x00AE }, 62 { "hibar", 0xAF, 0x00AF }, 63 { "deg", 0xB0, 0x00B0 }, 64 { "plusmn", 0xB1, 0x00B1 }, 65 { "sup2", 0xB2, 0x00B2 }, 66 { "sup3", 0xB3, 0x00B3 }, 67 { "acute", 0xB4, 0x00B4 }, 68 { "micro", 0xB5, 0x00B5 }, 69 { "para", 0xB6, 0x00B6 }, 70 { "middot", 0xB7, 0x00B7 }, 71 { "cedil", 0xB8, 0x00B8 }, 72 { "sup1", 0xB9, 0x00B9 }, 73 { "ordm", 0xBA, 0x00BA }, 74 { "raquo", 0xBB, 0x00BB }, 75 { "frac14", 0xBC, 0x00BC }, 76 { "frac12", 0xBD, 0x00BD }, 77 { "frac34", 0xBE, 0x00BE }, 78 { "iquest", 0xBF, 0x00BF }, 79 { "Agrave", 0xC0, 0x00C0 }, 80 { "Aacute", 0xC1, 0x00C1 }, 81 { "Acirc", 0xC2, 0x00C2 }, 82 { "Atilde", 0xC3, 0x00C3 }, 83 { "Auml", 0xC4, 0x00C4 }, 84 { "Aring", 0xC5, 0x00C5 }, 85 { "AElig", 0xC6, 0x00C6 }, 86 { "Ccedil", 0xC7, 0x00C7 }, 87 { "Ccedil", 0xC7, 0x00C7 }, 88 { "Egrave", 0xC8, 0x00C8 }, 89 { "Eacute", 0xC9, 0x00C9 }, 90 { "Ecirc", 0xCA, 0x00CA }, 91 { "Euml", 0xCB, 0x00CB }, 92 { "Igrave", 0xCC, 0x00CC }, 93 { "Iacute", 0xCD, 0x00CD }, 94 { "Icirc", 0xCE, 0x00CE }, 95 { "Iuml", 0xCF, 0x00CF }, 96 { "ETH", 0xD0, 0x00D0 }, 97 { "Ntilde", 0xD1, 0x00D1 }, 98 { "Ograve", 0xD2, 0x00D2 }, 99 { "Oacute", 0xD3, 0x00D3 }, 100 { "Ocirc", 0xD4, 0x00D4 }, 101 { "Otilde", 0xD5, 0x00D5 }, 102 { "Ouml", 0xD6, 0x00D6 }, 103 { "times", 0xD7, 0x00D7 }, 104 { "Oslash", 0xD8, 0x00D8 }, 105 { "Ugrave", 0xD9, 0x00D9 }, 106 { "Uacute", 0xDA, 0x00DA }, 107 { "Ucirc", 0xDB, 0x00DB }, 108 { "Uuml", 0xDC, 0x00DC }, 109 { "Yacute", 0xDD, 0x00DD }, 110 { "THORN", 0xDE, 0x00DE }, 111 { "szlig", 0xDF, 0x00DF }, 112 { "agrave", 0xE0, 0x00E0 }, 113 { "aacute", 0xE1, 0x00E1 }, 114 { "acirc", 0xE2, 0x00E2 }, 115 { "atilde", 0xE3, 0x00E3 }, 116 { "auml", 0xE4, 0x00E4 }, 117 { "aring", 0xE5, 0x00E5 }, 118 { "aelig", 0xE6, 0x00E6 }, 119 { "ccedil", 0xE7, 0x00E7 }, 120 { "egrave", 0xE8, 0x00E8 }, 121 { "eacute", 0xE9, 0x00E9 }, 122 { "ecirc", 0xEA, 0x00EA }, 123 { "euml", 0xEB, 0x00EB }, 124 { "igrave", 0xEC, 0x00EC }, 125 { "iacute", 0xED, 0x00ED }, 126 { "icirc", 0xEE, 0x00EE }, 127 { "iuml", 0xEF, 0x00EF }, 128 { "eth", 0xF0, 0x00F0 }, 129 { "ntilde", 0xF1, 0x00F1 }, 130 { "ograve", 0xF2, 0x00F2 }, 131 { "oacute", 0xF3, 0x00F3 }, 132 { "ocirc", 0xF4, 0x00F4 }, 133 { "otilde", 0xF5, 0x00F5 }, 134 { "ouml", 0xF6, 0x00F6 }, 135 { "divide", 0xF7, 0x00F7 }, 136 { "oslash", 0xF8, 0x00F8 }, 137 { "ugrave", 0xF9, 0x00F9 }, 138 { "uacute", 0xFA, 0x00FA }, 139 { "ucirc", 0xFB, 0x00FB }, 140 { "uuml", 0xFC, 0x00FC }, 141 { "yacute", 0xFD, 0x00FD }, 142 { "thorn", 0xFE, 0x00FE }, 143 { "yuml", 0xFF, 0x00FF }, 144 { NULL, 0, 0 } 145 }; 146 147 148 /* ISO 8859-15, also known as Latin 9, differs from Latin 1 in only a 150 few positions. http://www.cs.tut.fi/~jkorpela/latin9.html has a good 151 explanation and listing, summarized here. The names are abbreviated 152 from the official Unicode names, to fit in a decent line length. 153 154 code position 155 dec oct hex latin1 latin1 name latin9 latin9 name 156 157 164 0244 0xA4 U+00A4 currency symbol U+20AC euro sign 158 166 0246 0xA6 U+00A6 broken bar U+0160 S with caron 159 168 0250 0xA8 U+00A8 diaeresis U+0161 s with caron 160 180 0264 0xB4 U+00B4 acute accent U+017D Z with caron 161 184 0270 0xB8 U+00B8 cedilla U+017E z with caron 162 188 0274 0xBC U+00BC fraction 1/4 U+0152 ligature OE 163 189 0275 0xBD U+00BD fraction 1/2 U+0153 ligature oe 164 190 0276 0xBE U+00BE fraction 3/4 U+0178 Y with diaeresis 165 */ 166 167 static iso_map_type iso8859_15_map [] = { 168 { "nbsp", 0xA0, 0x00A0 }, 169 { "iexcl", 0xA1, 0x00A1 }, 170 { "cent", 0xA2, 0x00A2 }, 171 { "pound", 0xA3, 0x00A3 }, 172 { "euro", 0xA4, 0x20AC }, 173 { "yen", 0xA5, 0x00A5 }, 174 { "Scaron", 0xA6, 0x0160 }, 175 { "sect", 0xA7, 0x00A7 }, 176 { "scaron", 0xA8, 0x0161 }, 177 { "copy", 0xA9, 0x00A9 }, 178 { "ordf", 0xAA, 0x00AA }, 179 { "laquo", 0xAB, 0x00AB }, 180 { "not", 0xAC, 0x00AC }, 181 { "shy", 0xAD, 0x00AD }, 182 { "reg", 0xAE, 0x00AE }, 183 { "hibar", 0xAF, 0x00AF }, 184 { "deg", 0xB0, 0x00B0 }, 185 { "plusmn", 0xB1, 0x00B1 }, 186 { "sup2", 0xB2, 0x00B2 }, 187 { "sup3", 0xB3, 0x00B3 }, 188 { "Zcaron", 0xB4, 0x017D }, 189 { "micro", 0xB5, 0x00B5 }, 190 { "para", 0xB6, 0x00B6 }, 191 { "middot", 0xB7, 0x00B7 }, 192 { "zcaron", 0xB8, 0x017E }, 193 { "sup1", 0xB9, 0x00B9 }, 194 { "ordm", 0xBA, 0x00BA }, 195 { "raquo", 0xBB, 0x00BB }, 196 { "OElig", 0xBC, 0x0152 }, 197 { "oelig", 0xBD, 0x0153 }, 198 { "Yuml", 0xBE, 0x0178 }, 199 { "iquest", 0xBF, 0x00BF }, 200 { "Agrave", 0xC0, 0x00C0 }, 201 { "Aacute", 0xC1, 0x00C1 }, 202 { "Acirc", 0xC2, 0x00C2 }, 203 { "Atilde", 0xC3, 0x00C3 }, 204 { "Auml", 0xC4, 0x00C4 }, 205 { "Aring", 0xC5, 0x00C5 }, 206 { "AElig", 0xC6, 0x00C6 }, 207 { "Ccedil", 0xC7, 0x00C7 }, 208 { "Ccedil", 0xC7, 0x00C7 }, 209 { "Egrave", 0xC8, 0x00C8 }, 210 { "Eacute", 0xC9, 0x00C9 }, 211 { "Ecirc", 0xCA, 0x00CA }, 212 { "Euml", 0xCB, 0x00CB }, 213 { "Igrave", 0xCC, 0x00CC }, 214 { "Iacute", 0xCD, 0x00CD }, 215 { "Icirc", 0xCE, 0x00CE }, 216 { "Iuml", 0xCF, 0x00CF }, 217 { "ETH", 0xD0, 0x00D0 }, 218 { "Ntilde", 0xD1, 0x00D1 }, 219 { "Ograve", 0xD2, 0x00D2 }, 220 { "Oacute", 0xD3, 0x00D3 }, 221 { "Ocirc", 0xD4, 0x00D4 }, 222 { "Otilde", 0xD5, 0x00D5 }, 223 { "Ouml", 0xD6, 0x00D6 }, 224 { "times", 0xD7, 0x00D7 }, 225 { "Oslash", 0xD8, 0x00D8 }, 226 { "Ugrave", 0xD9, 0x00D9 }, 227 { "Uacute", 0xDA, 0x00DA }, 228 { "Ucirc", 0xDB, 0x00DB }, 229 { "Uuml", 0xDC, 0x00DC }, 230 { "Yacute", 0xDD, 0x00DD }, 231 { "THORN", 0xDE, 0x00DE }, 232 { "szlig", 0xDF, 0x00DF }, 233 { "agrave", 0xE0, 0x00E0 }, 234 { "aacute", 0xE1, 0x00E1 }, 235 { "acirc", 0xE2, 0x00E2 }, 236 { "atilde", 0xE3, 0x00E3 }, 237 { "auml", 0xE4, 0x00E4 }, 238 { "aring", 0xE5, 0x00E5 }, 239 { "aelig", 0xE6, 0x00E6 }, 240 { "ccedil", 0xE7, 0x00E7 }, 241 { "egrave", 0xE8, 0x00E8 }, 242 { "eacute", 0xE9, 0x00E9 }, 243 { "ecirc", 0xEA, 0x00EA }, 244 { "euml", 0xEB, 0x00EB }, 245 { "igrave", 0xEC, 0x00EC }, 246 { "iacute", 0xED, 0x00ED }, 247 { "icirc", 0xEE, 0x00EE }, 248 { "iuml", 0xEF, 0x00EF }, 249 { "eth", 0xF0, 0x00F0 }, 250 { "ntilde", 0xF1, 0x00F1 }, 251 { "ograve", 0xF2, 0x00F2 }, 252 { "oacute", 0xF3, 0x00F3 }, 253 { "ocirc", 0xF4, 0x00F4 }, 254 { "otilde", 0xF5, 0x00F5 }, 255 { "ouml", 0xF6, 0x00F6 }, 256 { "divide", 0xF7, 0x00F7 }, 257 { "oslash", 0xF8, 0x00F8 }, 258 { "ugrave", 0xF9, 0x00F9 }, 259 { "uacute", 0xFA, 0x00FA }, 260 { "ucirc", 0xFB, 0x00FB }, 261 { "uuml", 0xFC, 0x00FC }, 262 { "yacute", 0xFD, 0x00FD }, 263 { "thorn", 0xFE, 0x00FE }, 264 { "yuml", 0xFF, 0x00FF }, 265 { NULL, 0, 0 } 266 }; 267 268 269 270 /* Date: Mon, 31 Mar 2003 00:19:28 +0200 272 From: Wojciech Polak <polak (at) gnu.org> 273 ... 274 * Primary Polish site for ogonki is http://www.agh.edu.pl/ogonki/, 275 but it's only in Polish language (it has some interesting links). 276 277 * A general site about ISO 8859-2 at http://nl.ijs.si/gnusl/cee/iso8859-2.html 278 279 * ISO 8859-2 Character Set at http://nl.ijs.si/gnusl/cee/charset.html 280 This site provides almost all information about iso-8859-2, 281 including the character table!!! (must see!) 282 283 * ISO 8859-2 and even HTML entities !!! (must see!) 284 http://people.ssh.fi/mtr/genscript/88592.txt 285 286 * (minor) http://www.agh.edu.pl/ogonki/plchars.html 287 One more table, this time it includes even information about Polish 288 characters in Unicode. 289 */ 290 291 static iso_map_type iso8859_2_map [] = { 292 { "nbsp", 0xA0, 0x00A0 }, /* NO-BREAK SPACE */ 293 { "", 0xA1, 0x0104 }, /* LATIN CAPITAL LETTER A WITH OGONEK */ 294 { "", 0xA2, 0x02D8 }, /* BREVE */ 295 { "", 0xA3, 0x0141 }, /* LATIN CAPITAL LETTER L WITH STROKE */ 296 { "curren", 0xA4, 0x00A4 }, /* CURRENCY SIGN */ 297 { "", 0xA5, 0x013D }, /* LATIN CAPITAL LETTER L WITH CARON */ 298 { "", 0xA6, 0x015A }, /* LATIN CAPITAL LETTER S WITH ACUTE */ 299 { "sect", 0xA7, 0x00A7 }, /* SECTION SIGN */ 300 { "uml", 0xA8, 0x00A8 }, /* DIAERESIS */ 301 { "", 0xA9, 0x0160 }, /* LATIN CAPITAL LETTER S WITH CARON */ 302 { "", 0xAA, 0x015E }, /* LATIN CAPITAL LETTER S WITH CEDILLA */ 303 { "", 0xAB, 0x0164 }, /* LATIN CAPITAL LETTER T WITH CARON */ 304 { "", 0xAC, 0x0179 }, /* LATIN CAPITAL LETTER Z WITH ACUTE */ 305 { "shy", 0xAD, 0x00AD }, /* SOFT HYPHEN */ 306 { "", 0xAE, 0x017D }, /* LATIN CAPITAL LETTER Z WITH CARON */ 307 { "", 0xAF, 0x017B }, /* LATIN CAPITAL LETTER Z WITH DOT ABOVE */ 308 { "deg", 0xB0, 0x00B0 }, /* DEGREE SIGN */ 309 { "", 0xB1, 0x0105 }, /* LATIN SMALL LETTER A WITH OGONEK */ 310 { "", 0xB2, 0x02DB }, /* OGONEK */ 311 { "", 0xB3, 0x0142 }, /* LATIN SMALL LETTER L WITH STROKE */ 312 { "acute", 0xB4, 0x00B4 }, /* ACUTE ACCENT */ 313 { "", 0xB5, 0x013E }, /* LATIN SMALL LETTER L WITH CARON */ 314 { "", 0xB6, 0x015B }, /* LATIN SMALL LETTER S WITH ACUTE */ 315 { "", 0xB7, 0x02C7 }, /* CARON (Mandarin Chinese third tone) */ 316 { "cedil", 0xB8, 0x00B8 }, /* CEDILLA */ 317 { "", 0xB9, 0x0161 }, /* LATIN SMALL LETTER S WITH CARON */ 318 { "", 0xBA, 0x015F }, /* LATIN SMALL LETTER S WITH CEDILLA */ 319 { "", 0xBB, 0x0165 }, /* LATIN SMALL LETTER T WITH CARON */ 320 { "", 0xBC, 0x017A }, /* LATIN SMALL LETTER Z WITH ACUTE */ 321 { "", 0xBD, 0x02DD }, /* DOUBLE ACUTE ACCENT */ 322 { "", 0xBE, 0x017E }, /* LATIN SMALL LETTER Z WITH CARON */ 323 { "", 0xBF, 0x017C }, /* LATIN SMALL LETTER Z WITH DOT ABOVE */ 324 { "", 0xC0, 0x0154 }, /* LATIN CAPITAL LETTER R WITH ACUTE */ 325 { "", 0xC1, 0x00C1 }, /* LATIN CAPITAL LETTER A WITH ACUTE */ 326 { "", 0xC2, 0x00C2 }, /* LATIN CAPITAL LETTER A WITH CIRCUMFLEX */ 327 { "", 0xC3, 0x0102 }, /* LATIN CAPITAL LETTER A WITH BREVE */ 328 { "", 0xC4, 0x00C4 }, /* LATIN CAPITAL LETTER A WITH DIAERESIS */ 329 { "", 0xC5, 0x0139 }, /* LATIN CAPITAL LETTER L WITH ACUTE */ 330 { "", 0xC6, 0x0106 }, /* LATIN CAPITAL LETTER C WITH ACUTE */ 331 { "", 0xC7, 0x00C7 }, /* LATIN CAPITAL LETTER C WITH CEDILLA */ 332 { "", 0xC8, 0x010C }, /* LATIN CAPITAL LETTER C WITH CARON */ 333 { "", 0xC9, 0x00C9 }, /* LATIN CAPITAL LETTER E WITH ACUTE */ 334 { "", 0xCA, 0x0118 }, /* LATIN CAPITAL LETTER E WITH OGONEK */ 335 { "", 0xCB, 0x00CB }, /* LATIN CAPITAL LETTER E WITH DIAERESIS */ 336 { "", 0xCC, 0x011A }, /* LATIN CAPITAL LETTER E WITH CARON */ 337 { "", 0xCD, 0x00CD }, /* LATIN CAPITAL LETTER I WITH ACUTE */ 338 { "", 0xCE, 0x00CE }, /* LATIN CAPITAL LETTER I WITH CIRCUMFLEX */ 339 { "", 0xCF, 0x010E }, /* LATIN CAPITAL LETTER D WITH CARON */ 340 { "", 0xD0, 0x0110 }, /* LATIN CAPITAL LETTER D WITH STROKE */ 341 { "", 0xD1, 0x0143 }, /* LATIN CAPITAL LETTER N WITH ACUTE */ 342 { "", 0xD2, 0x0147 }, /* LATIN CAPITAL LETTER N WITH CARON */ 343 { "", 0xD3, 0x00D3 }, /* LATIN CAPITAL LETTER O WITH ACUTE */ 344 { "", 0xD4, 0x00D4 }, /* LATIN CAPITAL LETTER O WITH CIRCUMFLEX */ 345 { "", 0xD5, 0x0150 }, /* LATIN CAPITAL LETTER O WITH DOUBLE ACUTE */ 346 { "", 0xD6, 0x00D6 }, /* LATIN CAPITAL LETTER O WITH DIAERESIS */ 347 { "times", 0xD7, 0x00D7 }, /* MULTIPLICATION SIGN */ 348 { "", 0xD8, 0x0158 }, /* LATIN CAPITAL LETTER R WITH CARON */ 349 { "", 0xD9, 0x016E }, /* LATIN CAPITAL LETTER U WITH RING ABOVE */ 350 { "", 0xDA, 0x00DA }, /* LATIN CAPITAL LETTER U WITH ACUTE */ 351 { "", 0xDB, 0x0170 }, /* LATIN CAPITAL LETTER U WITH DOUBLE ACUTE */ 352 { "", 0xDC, 0x00DC }, /* LATIN CAPITAL LETTER U WITH DIAERESIS */ 353 { "", 0xDD, 0x00DD }, /* LATIN CAPITAL LETTER Y WITH ACUTE */ 354 { "", 0xDE, 0x0162 }, /* LATIN CAPITAL LETTER T WITH CEDILLA */ 355 { "", 0xDF, 0x00DF }, /* LATIN SMALL LETTER SHARP S (German) */ 356 { "", 0xE0, 0x0155 }, /* LATIN SMALL LETTER R WITH ACUTE */ 357 { "", 0xE1, 0x00E1 }, /* LATIN SMALL LETTER A WITH ACUTE */ 358 { "", 0xE2, 0x00E2 }, /* LATIN SMALL LETTER A WITH CIRCUMFLEX */ 359 { "", 0xE3, 0x0103 }, /* LATIN SMALL LETTER A WITH BREVE */ 360 { "", 0xE4, 0x00E4 }, /* LATIN SMALL LETTER A WITH DIAERESIS */ 361 { "", 0xE5, 0x013A }, /* LATIN SMALL LETTER L WITH ACUTE */ 362 { "", 0xE6, 0x0107 }, /* LATIN SMALL LETTER C WITH ACUTE */ 363 { "", 0xE7, 0x00E7 }, /* LATIN SMALL LETTER C WITH CEDILLA */ 364 { "", 0xE8, 0x010D }, /* LATIN SMALL LETTER C WITH CARON */ 365 { "", 0xE9, 0x00E9 }, /* LATIN SMALL LETTER E WITH ACUTE */ 366 { "", 0xEA, 0x0119 }, /* LATIN SMALL LETTER E WITH OGONEK */ 367 { "", 0xEB, 0x00EB }, /* LATIN SMALL LETTER E WITH DIAERESIS */ 368 { "", 0xEC, 0x011B }, /* LATIN SMALL LETTER E WITH CARON */ 369 { "", 0xED, 0x00ED }, /* LATIN SMALL LETTER I WITH ACUTE */ 370 { "", 0xEE, 0x00EE }, /* LATIN SMALL LETTER I WITH CIRCUMFLEX */ 371 { "", 0xEF, 0x010F }, /* LATIN SMALL LETTER D WITH CARON */ 372 { "", 0xF0, 0x0111 }, /* LATIN SMALL LETTER D WITH STROKE */ 373 { "", 0xF1, 0x0144 }, /* LATIN SMALL LETTER N WITH ACUTE */ 374 { "", 0xF2, 0x0148 }, /* LATIN SMALL LETTER N WITH CARON */ 375 { "", 0xF3, 0x00F3 }, /* LATIN SMALL LETTER O WITH ACUTE */ 376 { "", 0xF4, 0x00F4 }, /* LATIN SMALL LETTER O WITH CIRCUMFLEX */ 377 { "", 0xF5, 0x0151 }, /* LATIN SMALL LETTER O WITH DOUBLE ACUTE */ 378 { "", 0xF6, 0x00F6 }, /* LATIN SMALL LETTER O WITH DIAERESIS */ 379 { "divide", 0xF7, 0x00F7 }, /* DIVISION SIGN */ 380 { "", 0xF8, 0x0159 }, /* LATIN SMALL LETTER R WITH CARON */ 381 { "", 0xF9, 0x016F }, /* LATIN SMALL LETTER U WITH RING ABOVE */ 382 { "", 0xFA, 0x00FA }, /* LATIN SMALL LETTER U WITH ACUTE */ 383 { "", 0xFB, 0x0171 }, /* LATIN SMALL LETTER U WITH DOUBLE ACUTE */ 384 { "", 0xFC, 0x00FC }, /* LATIN SMALL LETTER U WITH DIAERESIS */ 385 { "", 0xFD, 0x00FD }, /* LATIN SMALL LETTER Y WITH ACUTE */ 386 { "", 0xFE, 0x0163 }, /* LATIN SMALL LETTER T WITH CEDILLA */ 387 { "", 0xFF, 0x02D9 }, /* DOT ABOVE (Mandarin Chinese light tone) */ 388 { NULL, 0, 0 } 389 }; 390 391 encoding_type encoding_table[] = { 392 { no_encoding, "(no encoding)", NULL }, 393 { US_ASCII, "US-ASCII", us_ascii_map }, 394 { ISO_8859_1, "iso-8859-1", (iso_map_type *) iso8859_1_map }, 395 { ISO_8859_2, "iso-8859-2", (iso_map_type *) iso8859_2_map }, 396 { ISO_8859_3, "iso-8859-3", NULL }, 397 { ISO_8859_4, "iso-8859-4", NULL }, 398 { ISO_8859_5, "iso-8859-5", NULL }, 399 { ISO_8859_6, "iso-8859-6", NULL }, 400 { ISO_8859_7, "iso-8859-7", NULL }, 401 { ISO_8859_8, "iso-8859-8", NULL }, 402 { ISO_8859_9, "iso-8859-9", NULL }, 403 { ISO_8859_10, "iso-8859-10", NULL }, 404 { ISO_8859_11, "iso-8859-11", NULL }, 405 { ISO_8859_12, "iso-8859-12", NULL }, 406 { ISO_8859_13, "iso-8859-13", NULL }, 407 { ISO_8859_14, "iso-8859-14", NULL }, 408 { ISO_8859_15, "iso-8859-15", (iso_map_type *) iso8859_15_map }, 409 { last_encoding_code, NULL, NULL } 410 }; 411 412 413 language_type language_table[] = { 414 { aa, "aa", "Afar" }, 415 { ab, "ab", "Abkhazian" }, 416 { af, "af", "Afrikaans" }, 417 { am, "am", "Amharic" }, 418 { ar, "ar", "Arabic" }, 419 { as, "as", "Assamese" }, 420 { ay, "ay", "Aymara" }, 421 { az, "az", "Azerbaijani" }, 422 { ba, "ba", "Bashkir" }, 423 { be, "be", "Byelorussian" }, 424 { bg, "bg", "Bulgarian" }, 425 { bh, "bh", "Bihari" }, 426 { bi, "bi", "Bislama" }, 427 { bn, "bn", "Bengali; Bangla" }, 428 { bo, "bo", "Tibetan" }, 429 { br, "br", "Breton" }, 430 { ca, "ca", "Catalan" }, 431 { co, "co", "Corsican" }, 432 { cs, "cs", "Czech" }, 433 { cy, "cy", "Welsh" }, 434 { da, "da", "Danish" }, 435 { de, "de", "German" }, 436 { dz, "dz", "Bhutani" }, 437 { el, "el", "Greek" }, 438 { en, "en", "English" }, 439 { eo, "eo", "Esperanto" }, 440 { es, "es", "Spanish" }, 441 { et, "et", "Estonian" }, 442 { eu, "eu", "Basque" }, 443 { fa, "fa", "Persian" }, 444 { fi, "fi", "Finnish" }, 445 { fj, "fj", "Fiji" }, 446 { fo, "fo", "Faroese" }, 447 { fr, "fr", "French" }, 448 { fy, "fy", "Frisian" }, 449 { ga, "ga", "Irish" }, 450 { gd, "gd", "Scots Gaelic" }, 451 { gl, "gl", "Galician" }, 452 { gn, "gn", "Guarani" }, 453 { gu, "gu", "Gujarati" }, 454 { ha, "ha", "Hausa" }, 455 { he, "he", "Hebrew" } /* (formerly iw) */, 456 { hi, "hi", "Hindi" }, 457 { hr, "hr", "Croatian" }, 458 { hu, "hu", "Hungarian" }, 459 { hy, "hy", "Armenian" }, 460 { ia, "ia", "Interlingua" }, 461 { id, "id", "Indonesian" } /* (formerly in) */, 462 { ie, "ie", "Interlingue" }, 463 { ik, "ik", "Inupiak" }, 464 { is, "is", "Icelandic" }, 465 { it, "it", "Italian" }, 466 { iu, "iu", "Inuktitut" }, 467 { ja, "ja", "Japanese" }, 468 { jw, "jw", "Javanese" }, 469 { ka, "ka", "Georgian" }, 470 { kk, "kk", "Kazakh" }, 471 { kl, "kl", "Greenlandic" }, 472 { km, "km", "Cambodian" }, 473 { kn, "kn", "Kannada" }, 474 { ko, "ko", "Korean" }, 475 { ks, "ks", "Kashmiri" }, 476 { ku, "ku", "Kurdish" }, 477 { ky, "ky", "Kirghiz" }, 478 { la, "la", "Latin" }, 479 { ln, "ln", "Lingala" }, 480 { lo, "lo", "Laothian" }, 481 { lt, "lt", "Lithuanian" }, 482 { lv, "lv", "Latvian, Lettish" }, 483 { mg, "mg", "Malagasy" }, 484 { mi, "mi", "Maori" }, 485 { mk, "mk", "Macedonian" }, 486 { ml, "ml", "Malayalam" }, 487 { mn, "mn", "Mongolian" }, 488 { mo, "mo", "Moldavian" }, 489 { mr, "mr", "Marathi" }, 490 { ms, "ms", "Malay" }, 491 { mt, "mt", "Maltese" }, 492 { my, "my", "Burmese" }, 493 { na, "na", "Nauru" }, 494 { ne, "ne", "Nepali" }, 495 { nl, "nl", "Dutch" }, 496 { no, "no", "Norwegian" }, 497 { oc, "oc", "Occitan" }, 498 { om, "om", "(Afan) Oromo" }, 499 { or, "or", "Oriya" }, 500 { pa, "pa", "Punjabi" }, 501 { pl, "pl", "Polish" }, 502 { ps, "ps", "Pashto, Pushto" }, 503 { pt, "pt", "Portuguese" }, 504 { qu, "qu", "Quechua" }, 505 { rm, "rm", "Rhaeto-Romance" }, 506 { rn, "rn", "Kirundi" }, 507 { ro, "ro", "Romanian" }, 508 { ru, "ru", "Russian" }, 509 { rw, "rw", "Kinyarwanda" }, 510 { sa, "sa", "Sanskrit" }, 511 { sd, "sd", "Sindhi" }, 512 { sg, "sg", "Sangro" }, 513 { sh, "sh", "Serbo-Croatian" }, 514 { si, "si", "Sinhalese" }, 515 { sk, "sk", "Slovak" }, 516 { sl, "sl", "Slovenian" }, 517 { sm, "sm", "Samoan" }, 518 { sn, "sn", "Shona" }, 519 { so, "so", "Somali" }, 520 { sq, "sq", "Albanian" }, 521 { sr, "sr", "Serbian" }, 522 { ss, "ss", "Siswati" }, 523 { st, "st", "Sesotho" }, 524 { su, "su", "Sundanese" }, 525 { sv, "sv", "Swedish" }, 526 { sw, "sw", "Swahili" }, 527 { ta, "ta", "Tamil" }, 528 { te, "te", "Telugu" }, 529 { tg, "tg", "Tajik" }, 530 { th, "th", "Thai" }, 531 { ti, "ti", "Tigrinya" }, 532 { tk, "tk", "Turkmen" }, 533 { tl, "tl", "Tagalog" }, 534 { tn, "tn", "Setswana" }, 535 { to, "to", "Tonga" }, 536 { tr, "tr", "Turkish" }, 537 { ts, "ts", "Tsonga" }, 538 { tt, "tt", "Tatar" }, 539 { tw, "tw", "Twi" }, 540 { ug, "ug", "Uighur" }, 541 { uk, "uk", "Ukrainian" }, 542 { ur, "ur", "Urdu" }, 543 { uz, "uz", "Uzbek" }, 544 { vi, "vi", "Vietnamese" }, 545 { vo, "vo", "Volapuk" }, 546 { wo, "wo", "Wolof" }, 547 { xh, "xh", "Xhosa" }, 548 { yi, "yi", "Yiddish" } /* (formerly ji) */, 549 { yo, "yo", "Yoruba" }, 550 { za, "za", "Zhuang" }, 551 { zh, "zh", "Chinese" }, 552 { zu, "zu", "Zulu" }, 553 { last_language_code, NULL, NULL } 554 }; 555 556 /* @documentlanguage. Maybe we'll do something useful with this in the 558 future. For now, we just recognize it. */ 559 560 /* XML documents can make use of this data. Unfortunately, it clashes with 561 the structure currently used. So instead of enclosing content into 562 a language block, we just output an empty element. Anyways, a stream based 563 parser can make good use of it. */ 564 void 565 cm_documentlanguage (int arg, int arg2, int arg3) 566 { 567 language_code_type c; 568 char *lang_arg; 569 570 /* Read the line with the language code on it. */ 571 get_rest_of_line (0, &lang_arg); 572 573 /* Linear search is fine these days. */ 574 for (c = aa; c != last_language_code; c++) 575 { 576 if (strcmp (lang_arg, language_table[c].abbrev) == 0) 577 { /* Set current language code. */ 578 language_code = c; 579 break; 580 } 581 } 582 583 /* If we didn't find this code, complain. */ 584 if (c == last_language_code) 585 warning (_("%s is not a valid ISO 639 language code"), lang_arg); 586 587 if (xml && !docbook) 588 { 589 xml_insert_element_with_attribute (DOCUMENTLANGUAGE, START, "xml:lang=\"%s\"", lang_arg); 590 xml_insert_element (DOCUMENTLANGUAGE, END); 591 } 592 593 free (lang_arg); 594 } 595 596 597 598 /* Search through the encoding table for the given character, returning 600 its equivalent. */ 601 602 static int 603 cm_search_iso_map (char *html) 604 { 605 int i; 606 iso_map_type *iso = encoding_table[document_encoding_code].isotab; 607 608 /* If no conversion table for this encoding, quit. */ 609 if (!iso) 610 return -1; 611 612 for (i = 0; iso[i].html; i++) 613 { 614 if (strcmp (html, iso[i].html) == 0) 615 return i; 616 } 617 618 return -1; 619 } 620 621 622 /* @documentencoding. Set the translation table. */ 623 624 void 625 cm_documentencoding (int arg, int arg2, int arg3) 626 { 627 if (!handling_delayed_writes) 628 { 629 encoding_code_type enc; 630 char *enc_arg; 631 632 /* This is ugly and probably needs to apply to other commands' 633 argument parsing as well. When we're doing @documentencoding, 634 we're generally in the frontmatter of the document, and so the. 635 expansion in html/xml/docbook would generally be the empty string. 636 (Because those modes wait until the first normal text of the 637 document to start outputting.) The result would thus be a warning 638 "unrecognized encoding name `'". Sigh. */ 639 int save_html = html; 640 int save_xml = xml; 641 642 html = 0; 643 xml = 0; 644 get_rest_of_line (1, &enc_arg); 645 html = save_html; 646 xml = save_xml; 647 648 /* See if we have this encoding. */ 649 for (enc = no_encoding+1; enc != last_encoding_code; enc++) 650 { 651 if (strcasecmp (enc_arg, encoding_table[enc].encname) == 0) 652 { 653 document_encoding_code = enc; 654 break; 655 } 656 } 657 658 /* If we didn't find this code, complain. */ 659 if (enc == last_encoding_code) 660 { 661 warning (_("unrecognized encoding name `%s'"), enc_arg); 662 /* Let the previous one go. */ 663 if (unknown_encoding && *unknown_encoding) 664 free (unknown_encoding); 665 unknown_encoding = xstrdup (enc_arg); 666 } 667 668 else if (encoding_table[document_encoding_code].isotab == NULL) 669 warning (_("sorry, encoding `%s' not supported"), enc_arg); 670 671 free (enc_arg); 672 } 673 else if (xml) 674 { 675 char *encoding = current_document_encoding (); 676 677 if (encoding && *encoding) 678 { 679 insert_string (" encoding=\""); 680 insert_string (encoding); 681 insert_string ("\""); 682 } 683 684 free (encoding); 685 } 686 } 687 688 char * 689 current_document_encoding (void) 690 { 691 if (document_encoding_code != no_encoding) 692 return xstrdup (encoding_table[document_encoding_code].encname); 693 else if (unknown_encoding && *unknown_encoding) 694 return xstrdup (unknown_encoding); 695 else 696 return xstrdup (""); 697 } 698 699 700 /* If html or xml output, add &HTML_STR; to the output. If not html and 701 the user requested encoded output, add the real 8-bit character 702 corresponding to HTML_STR from the translation tables. Otherwise, 703 add INFO_STR. */ 704 705 static void 706 add_encoded_char (char *html_str, char *info_str) 707 { 708 if (html) 709 add_word_args ("&%s;", html_str); 710 else if (xml) 711 xml_insert_entity (html_str); 712 else if (enable_encoding) 713 { 714 /* Look for HTML_STR in the current translation table. */ 715 int rc = cm_search_iso_map (html_str); 716 if (rc >= 0) 717 /* We found it, add the real character. */ 718 add_char (encoding_table[document_encoding_code].isotab[rc].bytecode); 719 else 720 { /* We didn't find it, that seems bad. */ 721 warning (_("invalid encoded character `%s'"), html_str); 722 add_word (info_str); 723 } 724 } 725 else 726 add_word (info_str); 727 } 728 729 730 731 /* Output an accent for HTML or XML. */ 733 734 static void 735 cm_accent_generic_html (int arg, int start, int end, char *html_supported, 736 int single, int html_solo_standalone, char *html_solo) 737 { 738 static int valid_html_accent; /* yikes */ 739 740 if (arg == START) 741 { /* If HTML has good support for this character, use it. */ 742 if (strchr (html_supported, curchar ())) 743 { /* Yes; start with an ampersand. The character itself 744 will be added later in read_command (makeinfo.c). */ 745 int saved_escape_html = escape_html; 746 escape_html = 0; 747 valid_html_accent = 1; 748 add_char ('&'); 749 escape_html = saved_escape_html; 750 } 751 else 752 { /* @dotless{i} is not listed in html_supported but HTML entities 753 starting with `i' can be used, such as î. */ 754 int save_input_text_offset = input_text_offset; 755 char *accent_contents; 756 757 get_until_in_braces ("\n", &accent_contents); 758 canon_white (accent_contents); 759 760 if (strstr (accent_contents, "@dotless{i")) 761 { 762 add_word_args ("&%c", accent_contents[9]); 763 valid_html_accent = 1; 764 } 765 else 766 { 767 /* Search for @dotless{} wasn't successful, so rewind. */ 768 input_text_offset = save_input_text_offset; 769 valid_html_accent = 0; 770 if (html_solo_standalone) 771 { /* No special HTML support, so produce standalone char. */ 772 if (xml) 773 xml_insert_entity (html_solo); 774 else 775 add_word_args ("&%s;", html_solo); 776 } 777 else 778 /* If the html_solo does not exist as standalone character 779 (namely ˆ ` ˜), then we use 780 the single character version instead. */ 781 add_char (single); 782 } 783 784 free (accent_contents); 785 } 786 } 787 else if (arg == END) 788 { /* Only if we saw a valid_html_accent can we use the full 789 HTML accent (umlaut, grave ...). */ 790 if (valid_html_accent) 791 { 792 add_word (html_solo); 793 add_char (';'); 794 } 795 } 796 } 797 798 799 static void 800 cm_accent_generic_no_headers (int arg, int start, int end, int single, 801 char *html_solo) 802 { 803 if (arg == END) 804 { 805 if (no_encoding) 806 add_char (single); 807 else 808 { 809 int rc; 810 char *buffer = xmalloc (1 + strlen (html_solo) + 1); 811 buffer[0] = output_paragraph[end - 1]; 812 buffer[1] = 0; 813 strcat (buffer, html_solo); 814 815 rc = cm_search_iso_map (buffer); 816 if (rc >= 0) 817 /* A little bit tricky ;-) 818 Here we replace the character which has 819 been inserted in read_command with 820 the value we have found in converting table 821 Does there exist a better way to do this? kama. */ 822 output_paragraph[end - 1] 823 = encoding_table[document_encoding_code].isotab[rc].bytecode; 824 else 825 { /* If we didn't find a translation for this character, 826 put the single instead. E.g., &Xuml; does not exist so X¨ 827 should be produced. */ 828 /* When the below warning is issued, an author has nothing 829 wrong in their document, let alone anything ``fixable'' 830 on their side. So it is commented out for now. */ 831 /* warning (_("%s is an invalid ISO code, using %c"), 832 buffer, single); */ 833 add_char (single); 834 } 835 836 free (buffer); 837 } 838 } 839 } 840 841 842 843 /* Accent commands that take explicit arguments and don't have any 845 special HTML support. */ 846 847 void 848 cm_accent (int arg, int arg2, int arg3) 849 { 850 int old_escape_html = escape_html; 851 escape_html = 0; 852 if (arg == START) 853 { 854 /* Must come first to avoid ambiguity with overdot. */ 855 if (strcmp (command, "udotaccent") == 0) /* underdot */ 856 add_char ('.'); 857 } 858 else if (arg == END) 859 { 860 if (strcmp (command, "=") == 0) /* macron */ 861 add_word ((html || xml) ? "¯" : "="); 862 else if (strcmp (command, "H") == 0) /* Hungarian umlaut */ 863 add_word ("''"); 864 else if (strcmp (command, "dotaccent") == 0) /* overdot */ 865 add_meta_char ('.'); 866 else if (strcmp (command, "ringaccent") == 0) /* ring */ 867 add_char ('*'); 868 else if (strcmp (command, "tieaccent") == 0) /* long tie */ 869 add_char ('['); 870 else if (strcmp (command, "u") == 0) /* breve */ 871 add_char ('('); 872 else if (strcmp (command, "ubaraccent") == 0) /* underbar */ 873 add_char ('_'); 874 else if (strcmp (command, "v") == 0) /* hacek/check */ 875 add_word ((html || xml) ? "<" : "<"); 876 } 877 escape_html = old_escape_html; 878 } 879 880 /* Common routine for the accent characters that have support in HTML. 881 If the character being accented is in the HTML_SUPPORTED set, then 882 produce &CHTML_SOLO;, for example, Ä for an A-umlaut. If not in 883 HTML_SUPPORTED, just produce &HTML_SOLO;X for the best we can do with 884 at an X-umlaut. If not producing HTML, just use SINGLE, a 885 character such as " which is the best plain text representation we 886 can manage. If HTML_SOLO_STANDALONE is nonzero the given HTML_SOLO 887 exists as valid standalone character in HTML, e.g., ¨. */ 888 889 static void 890 cm_accent_generic (int arg, int start, int end, char *html_supported, 891 int single, int html_solo_standalone, char *html_solo) 892 { 893 /* Accentuating space characters makes no sense, so issue a warning. */ 894 if (arg == START && isspace (input_text[input_text_offset])) 895 warning ("Accent command `@%s' must not be followed by whitespace", 896 command); 897 898 if (html || xml) 899 cm_accent_generic_html (arg, start, end, html_supported, 900 single, html_solo_standalone, html_solo); 901 else if (no_headers) 902 cm_accent_generic_no_headers (arg, start, end, single, html_solo); 903 else if (arg == END) 904 { 905 if (enable_encoding) 906 /* use 8-bit if available */ 907 cm_accent_generic_no_headers (arg, start, end, single, html_solo); 908 else 909 /* use regular character */ 910 add_char (single); 911 } 912 } 913 914 void 915 cm_accent_umlaut (int arg, int start, int end) 916 { 917 cm_accent_generic (arg, start, end, "aouAOUEeIiy", '"', 1, "uml"); 918 } 919 920 void 921 cm_accent_acute (int arg, int start, int end) 922 { 923 cm_accent_generic (arg, start, end, "AEIOUYaeiouy", '\'', 1, "acute"); 924 } 925 926 void 927 cm_accent_cedilla (int arg, int start, int end) 928 { 929 cm_accent_generic (arg, start, end, "Cc", ',', 1, "cedil"); 930 } 931 932 void 933 cm_accent_hat (int arg, int start, int end) 934 { 935 cm_accent_generic (arg, start, end, "AEIOUaeiou", '^', 0, "circ"); 936 } 937 938 void 939 cm_accent_grave (int arg, int start, int end) 940 { 941 cm_accent_generic (arg, start, end, "AEIOUaeiou", '`', 0, "grave"); 942 } 943 944 void 945 cm_accent_tilde (int arg, int start, int end) 946 { 947 cm_accent_generic (arg, start, end, "ANOano", '~', 0, "tilde"); 948 } 949 950 951 952 /* Non-English letters/characters that don't insert themselves. */ 954 void 955 cm_special_char (int arg, int arg2, int arg3) 956 { 957 int old_escape_html = escape_html; 958 escape_html = 0; 959 960 if (arg == START) 961 { 962 if ((*command == 'L' || *command == 'l' 963 || *command == 'O' || *command == 'o') 964 && command[1] == 0) 965 { /* Lslash lslash Oslash oslash. 966 Lslash and lslash aren't supported in HTML. */ 967 if (command[0] == 'O') 968 add_encoded_char ("Oslash", "/O"); 969 else if (command[0] == 'o') 970 add_encoded_char ("oslash", "/o"); 971 else 972 add_word_args ("/%c", command[0]); 973 } 974 else if (strcmp (command, "exclamdown") == 0) 975 add_encoded_char ("iexcl", "!"); 976 else if (strcmp (command, "questiondown") == 0) 977 add_encoded_char ("iquest", "?"); 978 else if (strcmp (command, "euro") == 0) 979 /* http://www.cs.tut.fi/~jkorpela/html/euro.html suggests that 980 € degrades best in old browsers. */ 981 add_encoded_char ("euro", "Euro "); 982 else if (strcmp (command, "pounds") == 0) 983 add_encoded_char ("pound" , "#"); 984 else if (strcmp (command, "ordf") == 0) 985 add_encoded_char ("ordf" , "a"); 986 else if (strcmp (command, "ordm") == 0) 987 add_encoded_char ("ordm" , "o"); 988 else if (strcmp (command, "AE") == 0) 989 add_encoded_char ("AElig", command); 990 else if (strcmp (command, "ae") == 0) 991 add_encoded_char ("aelig", command); 992 else if (strcmp (command, "OE") == 0) 993 add_encoded_char ("OElig", command); 994 else if (strcmp (command, "oe") == 0) 995 add_encoded_char ("oelig", command); 996 else if (strcmp (command, "AA") == 0) 997 add_encoded_char ("Aring", command); 998 else if (strcmp (command, "aa") == 0) 999 add_encoded_char ("aring", command); 1000 else if (strcmp (command, "ss") == 0) 1001 add_encoded_char ("szlig", command); 1002 else 1003 line_error ("cm_special_char internal error: command=@%s", command); 1004 } 1005 escape_html = old_escape_html; 1006 } 1007 1008 /* Dotless i or j. */ 1009 void 1010 cm_dotless (int arg, int start, int end) 1011 { 1012 if (arg == END) 1013 { 1014 xml_no_para --; 1015 if (output_paragraph[start] != 'i' && output_paragraph[start] != 'j') 1016 /* This error message isn't perfect if the argument is multiple 1017 characters, but it doesn't seem worth getting right. */ 1018 line_error (_("%c%s expects `i' or `j' as argument, not `%c'"), 1019 COMMAND_PREFIX, command, output_paragraph[start]); 1020 1021 else if (end - start != 1) 1022 line_error (_("%c%s expects a single character `i' or `j' as argument"), 1023 COMMAND_PREFIX, command); 1024 1025 /* We've already inserted the `i' or `j', so nothing to do. */ 1026 } 1027 else 1028 xml_no_para ++; 1029 } 1030