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