15a73ae64d0eb31f311f40ac2ecd47e81c57db2a
[debian/jabref.git] / src / java / net / sf / jabref / Globals.java
1 /* (C) 2003 Nizar N. Batada, Morten O. Alver
2
3  All programs in this directory and
4  subdirectories are published under the GNU General Public License as
5  described below.
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 of the License, or (at
10  your option) any later version.
11
12  This program is distributed in the hope that it will be useful, but
13  WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  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
20  USA
21
22  Further information about the GNU GPL is available at:
23  http://www.gnu.org/copyleft/gpl.ja.html
24
25  */
26 package net.sf.jabref;
27
28 import java.io.* ;
29 import java.nio.charset.Charset;
30 import java.util.* ;
31 import java.util.List;
32 import java.util.logging.* ;
33 import java.util.logging.Filter ;
34
35 import java.awt.* ;
36 import javax.swing.* ;
37
38 import net.sf.jabref.collab.* ;
39 import net.sf.jabref.imports.* ;
40 import net.sf.jabref.util.* ;
41 import net.sf.jabref.journals.JournalAbbreviations;
42
43 public class Globals {
44
45   public static int SHORTCUT_MASK,// = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
46       FUTURE_YEAR = 2050, // Needs to give a year definitely in the future. Used for guessing the
47                           // year field when parsing textual data.  :-)
48
49       STANDARD_EXPORT_COUNT = 5, // The number of standard export formats.
50       METADATA_LINE_LENGTH = 70; // The line length used to wrap metadata.
51
52   private static String resourcePrefix = "resource/JabRef",
53                         menuResourcePrefix = "resource/Menu",
54                         integrityResourcePrefix = "resource/IntegrityMessage";
55   private static final String buildInfos = "/resource/build.properties" ;
56   public static final String additionalFields = "/resource/fields/fields.xml" ;  // some extra field definitions
57   private static String logfile = "jabref.log";
58   public static ResourceBundle messages, menuTitles, intMessages ;
59   public static FileUpdateMonitor fileUpdateMonitor = new FileUpdateMonitor();
60     public static ImportFormatReader importFormatReader = new ImportFormatReader();
61
62   public static ErrorConsole errorConsole;
63
64    public static String VERSION,
65                        BUILD,
66                        BUILD_DATE ;
67
68   static
69   {
70     TBuildInfo bi = new TBuildInfo(buildInfos) ;
71     VERSION = bi.getBUILD_VERSION() ;
72     BUILD = bi.getBUILD_NUMBER() ;
73     BUILD_DATE = bi.getBUILD_DATE() ;
74
75       // TODO: Error console initialization here. When should it be used?
76       errorConsole = ErrorConsole.getInstance();
77   }
78
79
80
81   //public static ResourceBundle preferences = ResourceBundle.getBundle("resource/defaultPrefs");
82   public static Locale locale;
83   public static final String FILETYPE_PREFS_EXT = "_dir",
84       SELECTOR_META_PREFIX = "selector_",
85       LAYOUT_PREFIX = "/resource/layout/",
86       MAC = "Mac OS X",
87       DOI_LOOKUP_PREFIX = "http://dx.doi.org/",
88       NONE = "_non__",
89       FORMATTER_PACKAGE = "net.sf.jabref.export.layout.format.";
90   public static float duplicateThreshold = 0.75f;
91   private static Handler consoleHandler = new java.util.logging.ConsoleHandler();
92   public static String[] ENCODINGS,
93       ALL_ENCODINGS = //(String[]) Charset.availableCharsets().keySet().toArray(new String[]{});
94           new String[] {"ISO8859_1", "UTF8", "UTF-16", "ASCII",
95               "Cp1250", "Cp1251", "Cp1252", "Cp1253", "Cp1254", "Cp1257",
96               "JIS", "SJIS", "EUC-JP",      // Added Japanese encodings.
97               "Big5", "Big5_HKSCS", "GBK",
98               "ISO8859_2", "ISO8859_3", "ISO8859_4", "ISO8859_5", "ISO8859_6",
99               "ISO8859_7", "ISO8859_8", "ISO8859_9", "ISO8859_13", "ISO8859_15"};
100
101   // String array that maps from month number to month string label:
102   public static String[] MONTHS = new String[] {"jan", "feb", "mar", "apr", "may", "jun",
103           "jul", "aug", "sep", "oct", "nov", "dec"};
104
105   // Map that maps from month string labels to
106   public static Map MONTH_STRINGS = new HashMap();
107   static {
108       MONTH_STRINGS.put("jan", "January");
109       MONTH_STRINGS.put("feb", "February");
110       MONTH_STRINGS.put("mar", "March");
111       MONTH_STRINGS.put("apr", "April");
112       MONTH_STRINGS.put("may", "May");
113       MONTH_STRINGS.put("jun", "June");
114       MONTH_STRINGS.put("jul", "July");
115       MONTH_STRINGS.put("aug", "August");
116       MONTH_STRINGS.put("sep", "September");
117       MONTH_STRINGS.put("oct", "October");
118       MONTH_STRINGS.put("nov", "November");
119       MONTH_STRINGS.put("dec", "December");
120
121       // Build list of encodings, by filtering out all that are not supported
122       // on this system:
123       List encodings = new ArrayList();
124       for (int i=0; i<ALL_ENCODINGS.length; i++) {
125           if (Charset.isSupported(ALL_ENCODINGS[i]))
126             encodings.add(ALL_ENCODINGS[i]);
127       }
128       ENCODINGS = (String[])encodings.toArray(new String[0]);
129
130   }
131
132
133   public static GlobalFocusListener focusListener = new GlobalFocusListener();
134   public static JabRefPreferences prefs = null;
135  public static HelpDialog helpDiag = null;
136   public static String osName = System.getProperty("os.name", "def");
137   public static boolean ON_MAC = (osName.equals(MAC)),
138       ON_WIN = osName.startsWith("Windows");
139
140
141   public static String[] SKIP_WORDS = {"a", "an", "the", "for", "on"};
142     public static SidePaneManager sidePaneManager;
143   public static final String NEWLINE = System.getProperty("line.separator");
144     public static final boolean UNIX_NEWLINE = NEWLINE.equals("\n"); // true if we have unix newlines.
145
146     public static final String BIBTEX_STRING = "__string";
147     // "Fieldname" to indicate that a field should be treated as a bibtex string. Used when writing database to file.
148
149     public static void logger(String s) {
150     Logger.global.info(s);
151   }
152
153   public static void turnOffLogging() { // only log exceptions
154     Logger.global.setLevel(java.util.logging.Level.SEVERE);
155   }
156
157   // should be only called once
158   public static void turnOnConsoleLogging() {
159     Logger.global.addHandler(consoleHandler);
160
161   }
162
163
164
165   public static void turnOnFileLogging() {
166     Logger.global.setLevel(java.util.logging.Level.ALL);
167     java.util.logging.Handler handler;
168     handler = new ConsoleHandler();
169     /*try {
170       handler = new FileHandler(logfile); // this will overwrite
171     }
172     catch (IOException e) { //can't open log file so use console
173         e.printStackTrace();
174
175     } */
176     Logger.global.addHandler(handler);
177
178     handler.setFilter(new Filter() { // select what gets logged
179       public boolean isLoggable(LogRecord record) {
180         return true;
181       }
182     });
183   }
184
185   public static void setLanguage(String language, String country) {
186     locale = new Locale(language, country);
187     messages = ResourceBundle.getBundle(resourcePrefix, locale);
188     menuTitles = ResourceBundle.getBundle(menuResourcePrefix, locale);
189     intMessages = ResourceBundle.getBundle(integrityResourcePrefix, locale);
190     Locale.setDefault(locale);
191     javax.swing.JComponent.setDefaultLocale(locale);
192   }
193
194
195   public static JournalAbbreviations journalAbbrev;
196
197
198   public static String lang(String key, String[] params) {
199     String translation = null;
200     try {
201       if (Globals.messages != null) {
202         translation = Globals.messages.getString(key.replaceAll(" ", "_"));
203       }
204     }
205     catch (MissingResourceException ex) {
206       translation = key;
207       logger("Warning: could not get translation for \""
208                          + key + "\"");
209     }
210     if ((translation != null) && (translation.length() != 0)) {
211       translation = translation.replaceAll("_", " ");
212       StringBuffer sb = new StringBuffer();
213       boolean b = false;
214       char c;
215       for (int i = 0; i < translation.length(); ++i) {
216           c = translation.charAt(i);
217           if (c == '%') {
218               b = true;
219           } else {
220               if (!b) {
221                   sb.append(c);
222               } else {
223                   b = false;
224                   try {
225                       int index = Integer.parseInt(String.valueOf(c));
226                       if (params != null && index >= 0 && index <= params.length)
227                           sb.append(params[index]);
228                   } catch (NumberFormatException e) {
229                       // append literally (for quoting) or insert special symbol
230                       switch (c) {
231                       case 'c': // colon
232                           sb.append(':');
233                           break;
234                       case 'e': // equal
235                           sb.append('=');
236                           break;
237                       default: // anything else, e.g. %
238                           sb.append(c);
239                       }
240                   }
241               }
242           }
243       }
244       return sb.toString();
245     }
246     return key;
247   }
248
249   public static String lang(String key) {
250       return lang(key, (String[])null);
251   }
252
253   public static String lang(String key, String s1) {
254       return lang(key, new String[]{s1});
255   }
256
257   public static String lang(String key, String s1, String s2) {
258       return lang(key, new String[]{s1, s2});
259   }
260
261   public static String lang(String key, String s1, String s2, String s3) {
262       return lang(key, new String[]{s1, s2, s3});
263   }
264
265   public static String menuTitle(String key) {
266     String translation = null;
267     try {
268       if (Globals.messages != null) {
269         translation = Globals.menuTitles.getString(key.replaceAll(" ", "_"));
270       }
271     }
272     catch (MissingResourceException ex) {
273       translation = key;
274
275       //System.err.println("Warning: could not get menu item translation for \""
276       //                   + key + "\"");
277
278     }
279     if ((translation != null) && (translation.length() != 0)) {
280       return translation.replaceAll("_", " ");
281     }
282     else {
283       return key;
284     }
285   }
286
287   public static String getIntegrityMessage(String key)
288   {
289     String translation = null;
290     try {
291       if (Globals.intMessages != null) {
292         translation = Globals.intMessages.getString(key);
293       }
294     }
295     catch (MissingResourceException ex) {
296       translation = key;
297
298 //      System.err.println("Warning: could not get menu item translation for \""
299 //                         + key + "\"");
300     }
301     if ((translation != null) && (translation.length() != 0)) {
302       return translation ;
303     }
304     else {
305       return key;
306     }
307   }
308
309
310   //============================================================
311   // Using the hashmap of entry types found in BibtexEntryType
312   //============================================================
313   public static BibtexEntryType getEntryType(String type) {
314     // decide which entryType object to return
315     Object o = BibtexEntryType.ALL_TYPES.get(type);
316     if (o != null) {
317       return (BibtexEntryType) o;
318     }
319     else {
320       return BibtexEntryType.OTHER;
321     }
322     /*
323       if(type.equals("article"))
324         return BibtexEntryType.ARTICLE;
325       else if(type.equals("book"))
326         return BibtexEntryType.BOOK;
327       else if(type.equals("inproceedings"))
328         return BibtexEntryType.INPROCEEDINGS;
329      */
330   }
331
332     /**
333      * This method provides the correct opening brace to use when writing a field
334      * to BibTeX format.
335      * @return A String containing the braces to use.
336      */
337     public static String getOpeningBrace() {
338         return "{";
339         /*
340             As of version 2.0, storing all fields with double braces is no longer supported, because
341             it causes problems with e.g. the author field.
342
343         if (prefs.getBoolean("autoDoubleBraces"))
344             return "{{";
345         else
346             return "{";
347         */
348     }
349
350     /**
351      * This method provides the correct closing brace to use when writing a field
352      * to BibTeX format.
353      * @return A String containing the braces to use.
354      */
355     public static String getClosingBrace() {
356         return "}";
357         /*
358             As of version 2.0, storing all fields with double braces is no longer supported, because
359             it causes problems with e.g. the author field.
360
361         if (prefs.getBoolean("autoDoubleBraces"))
362             return "}}";
363         else
364         */
365
366     }
367
368     /*    public static void setupKeyBindings(JabRefPreferences prefs) {
369     }*/
370
371
372     public static String[] getMultipleFiles(JFrame owner,
373                                           File directory, String extension,
374                                           boolean updateWorkingdirectory) {
375
376         OpenFileFilter off = null;
377         if (extension == null)
378           off = new OpenFileFilter();
379         else if (!extension.equals(NONE))
380           off = new OpenFileFilter(extension);
381         return (String[])getNewFileImpl(owner, directory, extension, null, off,
382                 JFileChooser.OPEN_DIALOG, updateWorkingdirectory, false, true);
383     }
384
385   public static String getNewFile(JFrame owner,
386                                   File directory, String extension,
387                                   int dialogType,
388                                   boolean updateWorkingDirectory) {
389     return getNewFile(owner, directory, extension, null, dialogType,
390                       updateWorkingDirectory, false);
391   }
392
393
394   public static String getNewFile(JFrame owner,
395                                   File directory, String extension,
396                                   String description,
397                                   int dialogType,
398                                   boolean updateWorkingDirectory) {
399     return getNewFile(owner, directory, extension, description, dialogType,
400                       updateWorkingDirectory, false);
401   }
402
403
404   public static String getNewDir(JFrame owner,
405                                  File directory, String extension,
406                                  int dialogType, boolean updateWorkingDirectory) {
407     return getNewFile(owner, directory, extension, null, dialogType,
408                       updateWorkingDirectory, true);
409   }
410
411   public static String getNewDir(JFrame owner,
412                                  File directory, String extension,
413                                  String description,
414                                  int dialogType, boolean updateWorkingDirectory) {
415     return getNewFile(owner, directory, extension, description, dialogType,
416                       updateWorkingDirectory, true);
417   }
418
419   private static String getNewFile(JFrame owner,
420                                    File directory, String extension,
421                                    String description,
422                                    int dialogType,
423                                    boolean updateWorkingDirectory,
424                                    boolean dirOnly) {
425
426     OpenFileFilter off = null;
427
428     if (extension == null)
429       off = new OpenFileFilter();
430     else if (!extension.equals(NONE))
431       off = new OpenFileFilter(extension);
432
433     return (String)getNewFileImpl(owner, directory, extension, description, off,
434             dialogType, updateWorkingDirectory, dirOnly, false);
435   }
436
437   private static Object getNewFileImpl(JFrame owner,
438                                        File directory, String extension,
439                                        String description,
440                                        OpenFileFilter off,
441                                        int dialogType,
442                                        boolean updateWorkingDirectory,
443                                        boolean dirOnly,
444                                        boolean multipleSelection) {
445
446       if (ON_MAC) {
447           return getNewFileForMac(owner, directory, extension, dialogType,
448                   updateWorkingDirectory, dirOnly, off);
449       }
450
451       JFileChooser fc = null;
452       try {
453           fc = new JabRefFileChooser(directory);
454       } catch (InternalError errl) {
455           // This try/catch clause was added because a user reported an
456           // InternalError getting thrown on WinNT, presumably because of a
457           // bug in JGoodies Windows PLAF. This clause can be removed if the
458           // bug is fixed, but for now we just resort to the native file
459           // dialog, using the same method as is always used on Mac:
460           return getNewFileForMac(owner, directory, extension, dialogType,
461                   updateWorkingDirectory, dirOnly, off);
462       }
463
464       if (dirOnly) {
465           fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
466
467       }
468
469       fc.setMultiSelectionEnabled(multipleSelection);
470
471       fc.addChoosableFileFilter(off);
472       fc.setDialogType(dialogType);
473       int dialogResult = JFileChooser.CANCEL_OPTION;
474       if (dialogType == JFileChooser.OPEN_DIALOG) {
475           dialogResult = fc.showOpenDialog(owner);
476       } else if (dialogType == JFileChooser.SAVE_DIALOG) {
477           dialogResult = fc.showSaveDialog(owner);
478       } else {
479           dialogResult = fc.showDialog(owner, description);
480       }
481
482       // the getSelectedFile method returns a valid fileselection
483       // (if something is selected) indepentently from dialog return status
484       if (dialogResult != JFileChooser.APPROVE_OPTION)
485           return null;
486
487       // okay button
488       File selectedFile = fc.getSelectedFile();
489       if (selectedFile == null) { // cancel
490           return null;
491       }
492
493       // If this is a save dialog, and the user has not chosen "All files" as filter
494       // we enforce the given extension. But only if extension is not null.
495       if ((extension != null) && (dialogType == JFileChooser.SAVE_DIALOG) && (fc.getFileFilter() == off) &&
496               !off.accept(selectedFile)) {
497
498           // add the first extension if there are multiple extensions
499           selectedFile = new File(selectedFile.getPath() + extension.split("[, ]+", 0)[0]);
500       }
501
502       if (updateWorkingDirectory) {
503           prefs.put("workingDirectory", selectedFile.getPath());
504       }
505
506       if (!multipleSelection)
507         return selectedFile.getAbsolutePath();
508       else {
509           File[] files = fc.getSelectedFiles();
510           String[] filenames = new String[files.length];
511           for (int i=0; i<files.length; i++)
512             filenames[i] = files[i].getAbsolutePath();
513           return filenames;
514       }
515   }
516
517   private static String getNewFileForMac(JFrame owner,
518                                          File directory, String extensions,
519                                          int dialogType,
520                                          boolean updateWorkingDirectory,
521                                          boolean dirOnly,
522                                          FilenameFilter filter) {
523
524     FileDialog fc = new FileDialog(owner);
525     //fc.setFilenameFilter(filter);
526     if (directory != null) {
527       fc.setDirectory(directory.getParent());
528     }
529     if (dialogType == JFileChooser.OPEN_DIALOG) {
530       fc.setMode(FileDialog.LOAD);
531     }
532     else {
533       fc.setMode(FileDialog.SAVE);
534     }
535
536     fc.setVisible(true); // fc.show(); -> deprecated since 1.5
537
538     if (fc.getFile() != null) {
539       Globals.prefs.put("workingDirectory", fc.getDirectory() + fc.getFile());
540       return fc.getDirectory() + fc.getFile();
541     }
542     else {
543       return null;
544     }
545   }
546
547
548   public static String SPECIAL_COMMAND_CHARS = "\"`^~'c";
549   public static HashMap HTML_CHARS = new HashMap(),
550           HTMLCHARS = new HashMap(),
551       XML_CHARS = new HashMap(),
552       ASCII2XML_CHARS = new HashMap(),
553       UNICODE_CHARS = new HashMap(),
554       RTFCHARS = new HashMap(),
555         URL_CHARS = new HashMap();
556   static {
557
558       //System.out.println(journalAbbrev.getAbbreviatedName("Journal of Fish Biology", true));
559       //System.out.println(journalAbbrev.getAbbreviatedName("Journal of Fish Biology", false));
560       //System.out.println(journalAbbrev.getFullName("Aquaculture Eng."));
561       /*for (Iterator i=journalAbbrev.fullNameIterator(); i.hasNext();) {
562           String s = (String)i.next();
563           System.out.println(journalAbbrev.getFullName(s)+" : "+journalAbbrev.getAbbreviatedName(s, true));
564       } */
565
566     // Start the thread that monitors file time stamps.
567     //Util.pr("Starting FileUpdateMonitor thread. Globals line 293.");
568     fileUpdateMonitor.start();
569
570     try {
571       SHORTCUT_MASK = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
572     } catch (Throwable t) {
573
574     }
575
576       // Special characters in URLs need to be replaced to ensure that the URL
577       // opens properly on all platforms:
578       URL_CHARS.put("<", "%3c");
579       URL_CHARS.put(">", "%3e");
580       URL_CHARS.put("(", "%28");
581       URL_CHARS.put(")", "%29");
582       URL_CHARS.put(" ", "%20");
583       URL_CHARS.put("&", "%26");
584       URL_CHARS.put("$", "%24");
585
586
587
588 //    HTMLCHARS.put("\"a", "&auml;");
589 //    HTMLCHARS.put("\"A", "&Auml;");
590 //    HTMLCHARS.put("\"e", "&euml;");
591 //    HTMLCHARS.put("\"E", "&Euml;");
592 //    HTMLCHARS.put("\"i", "&iuml;");
593 //    HTMLCHARS.put("\"I", "&Iuml;");
594 //    HTMLCHARS.put("\"o", "&ouml;");
595 //    HTMLCHARS.put("\"O", "&Ouml;");
596 //    HTMLCHARS.put("\"u", "&uuml;");
597 //    HTMLCHARS.put("\"U", "&Uuml;");
598 //    HTMLCHARS.put("`a", "&agrave;");
599 //    HTMLCHARS.put("`A", "&Agrave;");
600 //    HTMLCHARS.put("`e", "&egrave;");
601 //    HTMLCHARS.put("`E", "&Egrave;");
602 //    HTMLCHARS.put("`i", "&igrave;");
603 //    HTMLCHARS.put("`I", "&Igrave;");
604 //    HTMLCHARS.put("`o", "&ograve;");
605 //    HTMLCHARS.put("`O", "&Ograve;");
606 //    HTMLCHARS.put("`u", "&ugrave;");
607 //    HTMLCHARS.put("`U", "&Ugrave;");
608 //    HTMLCHARS.put("'e", "&eacute;");
609 //    HTMLCHARS.put("'E", "&Eacute;");
610 //    HTMLCHARS.put("'i", "&iacute;");
611 //    HTMLCHARS.put("'I", "&Iacute;");
612 //    HTMLCHARS.put("'o", "&oacute;");
613 //    HTMLCHARS.put("'O", "&Oacute;");
614 //    HTMLCHARS.put("'u", "&uacute;");
615 //    HTMLCHARS.put("'U", "&Uacute;");
616 //    HTMLCHARS.put("'a", "&aacute;");
617 //    HTMLCHARS.put("'A", "&Aacute;");
618 //    HTMLCHARS.put("^a", "&ocirc;");
619 //    HTMLCHARS.put("^A", "&Ocirc;");
620 //    HTMLCHARS.put("^o", "&ocirc;");
621 //    HTMLCHARS.put("^O", "&Ocirc;");
622 //    HTMLCHARS.put("^u", "&ucirc;");
623 //    HTMLCHARS.put("^U", "&Ucirc;");
624 //    HTMLCHARS.put("^e", "&ecirc;");
625 //    HTMLCHARS.put("^E", "&Ecirc;");
626 //    HTMLCHARS.put("^i", "&icirc;");
627 //    HTMLCHARS.put("^I", "&Icirc;");
628 //    HTMLCHARS.put("~o", "&otilde;");
629 //    HTMLCHARS.put("~O", "&Otilde;");
630 //    HTMLCHARS.put("~n", "&ntilde;");
631 //    HTMLCHARS.put("~N", "&Ntilde;");
632 //    HTMLCHARS.put("~a", "&atilde;");
633 //    HTMLCHARS.put("~A", "&Atilde;");
634 //    HTMLCHARS.put("cc", "&ccedil;");
635 //    HTMLCHARS.put("cC", "&Ccedil;");
636
637
638       // Following character definitions contributed by Ervin Kolenovic:
639       // HTML named entities from #192 - #255 (UNICODE Latin-1)
640        HTMLCHARS.put("`A", "&Agrave;");    // #192
641        HTMLCHARS.put("'A", "&Aacute;");    // #193
642        HTMLCHARS.put("^A", "&Acirc;");     // #194
643        HTMLCHARS.put("~A", "&Atilde;");    // #195
644        HTMLCHARS.put("\"A", "&Auml;");     // #196
645        HTMLCHARS.put("AA", "&Aring;");     // #197
646        HTMLCHARS.put("AE", "&AElig;");     // #198
647        HTMLCHARS.put("cC", "&Ccedil;");    // #199
648        HTMLCHARS.put("`E", "&Egrave;");    // #200
649        HTMLCHARS.put("'E", "&Eacute;");    // #201
650        HTMLCHARS.put("^E", "&Ecirc;");     // #202
651        HTMLCHARS.put("\"E", "&Euml;");     // #203
652        HTMLCHARS.put("`I", "&Igrave;");    // #204
653        HTMLCHARS.put("'I", "&Iacute;");    // #205
654        HTMLCHARS.put("^I", "&Icirc;");     // #206
655        HTMLCHARS.put("\"I", "&Iuml;");     // #207
656        HTMLCHARS.put("DH", "&ETH;");       // #208
657        HTMLCHARS.put("~N", "&Ntilde;");    // #209
658        HTMLCHARS.put("`O", "&Ograve;");    // #210
659        HTMLCHARS.put("'O", "&Oacute;");    // #211
660        HTMLCHARS.put("^O", "&Ocirc;");     // #212
661        HTMLCHARS.put("~O", "&Otilde;");    // #213
662        HTMLCHARS.put("\"O", "&Ouml;");     // #214
663        // According to ISO 8859-1 the "\times" symbol should be placed here (#215).
664        // Omitting this, because it is a mathematical symbol.
665        HTMLCHARS.put("O", "&OSlash;");     // #216
666        HTMLCHARS.put("`U", "&Ugrave;");    // #217
667        HTMLCHARS.put("'U", "&Uacute;");    // #218
668        HTMLCHARS.put("^U", "&Ucirc;");     // #219
669        HTMLCHARS.put("\"U", "&Uuml;");     // #220
670        HTMLCHARS.put("'Y", "&Yacute;");    // #221
671        HTMLCHARS.put("TH", "&THORN;");     // #222
672        HTMLCHARS.put("ss", "&szlig;");     // #223
673        HTMLCHARS.put("`a", "&agrave;");    // #224
674        HTMLCHARS.put("'a", "&aacute;");    // #225
675        HTMLCHARS.put("^a", "&acirc;");     // #226
676        HTMLCHARS.put("~a", "&atilde;");    // #227
677        HTMLCHARS.put("\"a", "&auml;");     // #228
678        HTMLCHARS.put("aa", "&aring;");     // #229
679        HTMLCHARS.put("ae", "&aelig;");     // #230
680        HTMLCHARS.put("cc", "&ccedil;");    // #231
681        HTMLCHARS.put("`e", "&egrave;");    // #232
682        HTMLCHARS.put("'e", "&eacute;");    // #233
683        HTMLCHARS.put("^e", "&ecirc;");     // #234
684        HTMLCHARS.put("\"e", "&euml;");     // #235
685        HTMLCHARS.put("`i", "&igrave;");    // #236
686        HTMLCHARS.put("'i", "&iacute;");    // #237
687        HTMLCHARS.put("^i", "&icirc;");     // #238
688        HTMLCHARS.put("\"i", "&iuml;");     // #239
689        HTMLCHARS.put("dh", "&eth;");       // #240
690        HTMLCHARS.put("~n", "&ntilde;");    // #241
691        HTMLCHARS.put("`o", "&ograve;");    // #242
692        HTMLCHARS.put("'o", "&oacute;");    // #243
693        HTMLCHARS.put("^o", "&ocirc;");     // #244
694        HTMLCHARS.put("~o", "&otilde;");    // #245
695        HTMLCHARS.put("\"o", "&ouml;");     // #246
696        // According to ISO 8859-1 the "\div" symbol should be placed here (#247).
697        // Omitting this, because it is a mathematical symbol.
698        HTMLCHARS.put("o", "&oslash;");     // #248
699        HTMLCHARS.put("`u", "&ugrave;");    // #249
700        HTMLCHARS.put("'u", "&uacute;");    // #250
701        HTMLCHARS.put("^u", "&ucirc;");     // #251
702        HTMLCHARS.put("\"u", "&uuml;");     // #252
703        HTMLCHARS.put("'y", "&yacute;");    // #253
704        HTMLCHARS.put("th", "&thorn;");     // #254
705        HTMLCHARS.put("\"y", "&yuml;");     // #255
706
707        // HTML special characters without names (UNICODE Latin Extended-A), indicated by UNICODE number
708        HTMLCHARS.put("=A", "&#256;");      // "Amacr"
709        HTMLCHARS.put("=a", "&#257;");      // "amacr"
710        HTMLCHARS.put("uA", "&#258;");      // "Abreve"
711        HTMLCHARS.put("ua", "&#259;");      // "abreve"
712        HTMLCHARS.put("kA", "&#260;");      // "Aogon"
713        HTMLCHARS.put("ka", "&#261;");      // "aogon"
714        HTMLCHARS.put("'C", "&#262;");      // "Cacute"
715        HTMLCHARS.put("'c", "&#263;");      // "cacute"
716        HTMLCHARS.put("^C", "&#264;");      // "Ccirc"
717        HTMLCHARS.put("^c", "&#265;");      // "ccirc"
718        HTMLCHARS.put(".C", "&#266;");      // "Cdot"
719        HTMLCHARS.put(".c", "&#267;");      // "cdot"
720        HTMLCHARS.put("vC", "&#268;");      // "Ccaron"
721        HTMLCHARS.put("vc", "&#269;");      // "ccaron"
722        HTMLCHARS.put("vD", "&#270;");      // "Dcaron"
723        // Symbol #271 (d´) has no special Latex command
724        HTMLCHARS.put("DJ", "&#272;");      // "Dstrok"
725        HTMLCHARS.put("dj", "&#273;");      // "dstrok"
726        HTMLCHARS.put("=E", "&#274;");      // "Emacr"
727        HTMLCHARS.put("=e", "&#275;");      // "emacr"
728        HTMLCHARS.put("uE", "&#276;");      // "Ebreve"
729        HTMLCHARS.put("ue", "&#277;");      // "ebreve"
730        HTMLCHARS.put(".E", "&#278;");      // "Edot"
731        HTMLCHARS.put(".e", "&#279;");      // "edot"
732        HTMLCHARS.put("kE", "&#280;");      // "Eogon"
733        HTMLCHARS.put("ke", "&#281;");      // "eogon"
734        HTMLCHARS.put("vE", "&#282;");      // "Ecaron"
735        HTMLCHARS.put("ve", "&#283;");      // "ecaron"
736        HTMLCHARS.put("^G", "&#284;");      // "Gcirc"
737        HTMLCHARS.put("^g", "&#285;");      // "gcirc"
738        HTMLCHARS.put("uG", "&#286;");      // "Gbreve"
739        HTMLCHARS.put("ug", "&#287;");      // "gbreve"
740        HTMLCHARS.put(".G", "&#288;");      // "Gdot"
741        HTMLCHARS.put(".g", "&#289;");      // "gdot"
742        HTMLCHARS.put("cG", "&#290;");      // "Gcedil"
743        HTMLCHARS.put("'g", "&#291;");      // "gacute"
744        HTMLCHARS.put("^H", "&#292;");      // "Hcirc"
745        HTMLCHARS.put("^h", "&#293;");      // "hcirc"
746        HTMLCHARS.put("Hstrok", "&#294;");  // "Hstrok"
747        HTMLCHARS.put("hstrok", "&#295;");  // "hstrok"
748        HTMLCHARS.put("~I", "&#296;");      // "Itilde"
749        HTMLCHARS.put("~i", "&#297;");      // "itilde"
750        HTMLCHARS.put("=I", "&#298;");      // "Imacr"
751        HTMLCHARS.put("=i", "&#299;");      // "imacr"
752        HTMLCHARS.put("uI", "&#300;");      // "Ibreve"
753        HTMLCHARS.put("ui", "&#301;");      // "ibreve"
754        HTMLCHARS.put("kI", "&#302;");      // "Iogon"
755        HTMLCHARS.put("ki", "&#303;");      // "iogon"
756        HTMLCHARS.put(".I", "&#304;");      // "Idot"
757        HTMLCHARS.put("i", "&#305;");       // "inodot"
758        // Symbol #306 (IJ) has no special Latex command
759        // Symbol #307 (ij) has no special Latex command
760        HTMLCHARS.put("^J", "&#308;");      // "Jcirc"
761        HTMLCHARS.put("^j", "&#309;");      // "jcirc"
762        HTMLCHARS.put("cK", "&#310;");      // "Kcedil"
763        HTMLCHARS.put("ck", "&#311;");      // "kcedil"
764        // Symbol #312 (k) has no special Latex command
765        HTMLCHARS.put("'L", "&#313;");      // "Lacute"
766        HTMLCHARS.put("'l", "&#314;");      // "lacute"
767        HTMLCHARS.put("cL", "&#315;");      // "Lcedil"
768        HTMLCHARS.put("cl", "&#316;");      // "lcedil"
769        // Symbol #317 (L´) has no special Latex command
770        // Symbol #318 (l´) has no special Latex command
771        HTMLCHARS.put("Lmidot", "&#319;");      // "Lmidot"
772        HTMLCHARS.put("lmidot", "&#320;");      // "lmidot"
773        HTMLCHARS.put("L", "&#321;");      // "Lstrok"
774        HTMLCHARS.put("l", "&#322;");      // "lstrok"
775        HTMLCHARS.put("'N", "&#323;");      // "Nacute"
776        HTMLCHARS.put("'n", "&#324;");      // "nacute"
777        HTMLCHARS.put("cN", "&#325;");      // "Ncedil"
778        HTMLCHARS.put("cn", "&#326;");      // "ncedil"
779        HTMLCHARS.put("vN", "&#327;");      // "Ncaron"
780        HTMLCHARS.put("vn", "&#328;");      // "ncaron"
781        // Symbol #329 (´n) has no special Latex command
782        HTMLCHARS.put("NG", "&#330;");      // "ENG"
783        HTMLCHARS.put("ng", "&#331;");      // "eng"
784        HTMLCHARS.put("=O", "&#332;");      // "Omacr"
785        HTMLCHARS.put("=o", "&#333;");      // "omacr"
786        HTMLCHARS.put("uO", "&#334;");      // "Obreve"
787        HTMLCHARS.put("uo", "&#335;");      // "obreve"
788        HTMLCHARS.put("HO", "&#336;");      // "Odblac"
789        HTMLCHARS.put("Ho", "&#337;");      // "odblac"
790        HTMLCHARS.put("OE", "&#338;");      // "OElig"
791        HTMLCHARS.put("oe", "&#339;");      // "oelig"
792        HTMLCHARS.put("'R", "&#340;");      // "Racute"
793        HTMLCHARS.put("'r", "&#341;");      // "racute"
794        HTMLCHARS.put("cR", "&#342;");      // "Rcedil"
795        HTMLCHARS.put("cr", "&#343;");      // "rcedil"
796        HTMLCHARS.put("vR", "&#344;");      // "Rcaron"
797        HTMLCHARS.put("vr", "&#345;");      // "rcaron"
798        HTMLCHARS.put("'S", "&#346;");      // "Sacute"
799        HTMLCHARS.put("'s", "&#347;");      // "sacute"
800        HTMLCHARS.put("^S", "&#348;");      // "Scirc"
801        HTMLCHARS.put("^s", "&#349;");      // "scirc"
802        HTMLCHARS.put("cS", "&#350;");      // "Scedil"
803        HTMLCHARS.put("cs", "&#351;");      // "scedil"
804        HTMLCHARS.put("vS", "&#352;");      // "Scaron"
805        HTMLCHARS.put("vs", "&#353;");      // "scaron"
806        HTMLCHARS.put("cT", "&#354;");      // "Tcedil"
807        HTMLCHARS.put("ct", "&#355;");      // "tcedil"
808        HTMLCHARS.put("vT", "&#356;");      // "Tcaron"
809        // Symbol #357 (t´) has no special Latex command
810        HTMLCHARS.put("Tstrok", "&#358;");  // "Tstrok"
811        HTMLCHARS.put("tstrok", "&#359;");  // "tstrok"
812        HTMLCHARS.put("~U", "&#360;");      // "Utilde"
813        HTMLCHARS.put("~u", "&#361;");      // "utilde"
814        HTMLCHARS.put("=U", "&#362;");      // "Umacr"
815        HTMLCHARS.put("=u", "&#363;");      // "umacr"
816        HTMLCHARS.put("uU", "&#364;");      // "Ubreve"
817        HTMLCHARS.put("uu", "&#365;");      // "ubreve"
818        HTMLCHARS.put("rU", "&#366;");      // "Uring"
819        HTMLCHARS.put("ru", "&#367;");      // "uring"
820        HTMLCHARS.put("HU", "&#368;");      // "Odblac"
821        HTMLCHARS.put("Hu", "&#369;");      // "odblac"
822        HTMLCHARS.put("kU", "&#370;");      // "Uogon"
823        HTMLCHARS.put("ku", "&#371;");      // "uogon"
824        HTMLCHARS.put("^W", "&#372;");      // "Wcirc"
825        HTMLCHARS.put("^w", "&#373;");      // "wcirc"
826        HTMLCHARS.put("^Y", "&#374;");      // "Ycirc"
827        HTMLCHARS.put("^y", "&#375;");      // "ycirc"
828        HTMLCHARS.put("\"Y", "&#376;");     // "Yuml"
829        HTMLCHARS.put("'Z", "&#377;");      // "Zacute"
830        HTMLCHARS.put("'z", "&#378;");      // "zacute"
831        HTMLCHARS.put(".Z", "&#379;");      // "Zdot"
832        HTMLCHARS.put(".z", "&#380;");      // "zdot"
833        HTMLCHARS.put("vZ", "&#381;");      // "Zcaron"
834        HTMLCHARS.put("vz", "&#382;");      // "zcaron"
835        // Symbol #383 (f) has no special Latex command
836
837
838     XML_CHARS.put("\\{\\\\\\\"\\{a\\}\\}", "&#x00E4;");
839     XML_CHARS.put("\\{\\\\\\\"\\{A\\}\\}", "&#x00C4;");
840     XML_CHARS.put("\\{\\\\\\\"\\{e\\}\\}", "&#x00EB;");
841     XML_CHARS.put("\\{\\\\\\\"\\{E\\}\\}", "&#x00CB;");
842     XML_CHARS.put("\\{\\\\\\\"\\{i\\}\\}", "&#x00EF;");
843     XML_CHARS.put("\\{\\\\\\\"\\{I\\}\\}", "&#x00CF;");
844     XML_CHARS.put("\\{\\\\\\\"\\{o\\}\\}", "&#x00F6;");
845     XML_CHARS.put("\\{\\\\\\\"\\{O\\}\\}", "&#x00D6;");
846     XML_CHARS.put("\\{\\\\\\\"\\{u\\}\\}", "&#x00FC;");
847     XML_CHARS.put("\\{\\\\\\\"\\{U\\}\\}", "&#x00DC;");
848
849     XML_CHARS.put("\\{\\\\\\`\\{e\\}\\}", "&#x00E8;");
850     XML_CHARS.put("\\{\\\\\\`\\{E\\}\\}", "&#x00C8;");
851     XML_CHARS.put("\\{\\\\\\`\\{i\\}\\}", "&#x00EC;");
852     XML_CHARS.put("\\{\\\\\\`\\{I\\}\\}", "&#x00CC;");
853     XML_CHARS.put("\\{\\\\\\`\\{o\\}\\}", "&#x00F2;");
854     XML_CHARS.put("\\{\\\\\\`\\{O\\}\\}", "&#x00D2;");
855     XML_CHARS.put("\\{\\\\\\`\\{u\\}\\}", "&#x00F9;");
856     XML_CHARS.put("\\{\\\\\\`\\{U\\}\\}", "&#x00D9;");
857     XML_CHARS.put("\\{\\\\\\'\\{e\\}\\}", "&#x00E9;");
858     XML_CHARS.put("\\{\\\\\\\uFFFD\\{E\\}\\}", "&#x00C9;");
859     XML_CHARS.put("\\{\\\\\\\uFFFD\\{i\\}\\}", "&#x00ED;");
860     XML_CHARS.put("\\{\\\\\\\uFFFD\\{I\\}\\}", "&#x00CD;");
861     XML_CHARS.put("\\{\\\\\\\uFFFD\\{o\\}\\}", "&#x00F3;");
862     XML_CHARS.put("\\{\\\\\\\uFFFD\\{O\\}\\}", "&#x00D3;");
863     XML_CHARS.put("\\{\\\\\\\uFFFD\\{u\\}\\}", "&#x00FA;");
864     XML_CHARS.put("\\{\\\\\\\uFFFD\\{U\\}\\}", "&#x00DA;");
865     XML_CHARS.put("\\{\\\\\\\uFFFD\\{a\\}\\}", "&#x00E1;");
866     XML_CHARS.put("\\{\\\\\\\uFFFD\\{A\\}\\}", "&#x00C1;");
867
868     XML_CHARS.put("\\{\\\\\\^\\{o\\}\\}", "&#x00F4;");
869     XML_CHARS.put("\\{\\\\\\^\\{O\\}\\}", "&#x00D4;");
870     XML_CHARS.put("\\{\\\\\\^\\{u\\}\\}", "&#x00F9;");
871     XML_CHARS.put("\\{\\\\\\^\\{U\\}\\}", "&#x00D9;");
872     XML_CHARS.put("\\{\\\\\\^\\{e\\}\\}", "&#x00EA;");
873     XML_CHARS.put("\\{\\\\\\^\\{E\\}\\}", "&#x00CA;");
874     XML_CHARS.put("\\{\\\\\\^\\{i\\}\\}", "&#x00EE;");
875     XML_CHARS.put("\\{\\\\\\^\\{I\\}\\}", "&#x00CE;");
876     XML_CHARS.put("\\{\\\\\\~\\{o\\}\\}", "&#x00F5;");
877     XML_CHARS.put("\\{\\\\\\~\\{O\\}\\}", "&#x00D5;");
878     XML_CHARS.put("\\{\\\\\\~\\{n\\}\\}", "&#x00F1;");
879     XML_CHARS.put("\\{\\\\\\~\\{N\\}\\}", "&#x00D1;");
880     XML_CHARS.put("\\{\\\\\\~\\{a\\}\\}", "&#x00E3;");
881     XML_CHARS.put("\\{\\\\\\~\\{A\\}\\}", "&#x00C3;");
882
883
884     XML_CHARS.put("\\{\\\\\\\"a\\}", "&#x00E4;");
885     XML_CHARS.put("\\{\\\\\\\"A\\}", "&#x00C4;");
886     XML_CHARS.put("\\{\\\\\\\"e\\}", "&#x00EB;");
887     XML_CHARS.put("\\{\\\\\\\"E\\}", "&#x00CB;");
888     XML_CHARS.put("\\{\\\\\\\"i\\}", "&#x00EF;");
889     XML_CHARS.put("\\{\\\\\\\"I\\}", "&#x00CF;");
890     XML_CHARS.put("\\{\\\\\\\"o\\}", "&#x00F6;");
891     XML_CHARS.put("\\{\\\\\\\"O\\}", "&#x00D6;");
892     XML_CHARS.put("\\{\\\\\\\"u\\}", "&#x00FC;");
893     XML_CHARS.put("\\{\\\\\\\"U\\}", "&#x00DC;");
894
895     XML_CHARS.put("\\{\\\\\\`e\\}", "&#x00E8;");
896     XML_CHARS.put("\\{\\\\\\`E\\}", "&#x00C8;");
897     XML_CHARS.put("\\{\\\\\\`i\\}", "&#x00EC;");
898     XML_CHARS.put("\\{\\\\\\`I\\}", "&#x00CC;");
899     XML_CHARS.put("\\{\\\\\\`o\\}", "&#x00F2;");
900     XML_CHARS.put("\\{\\\\\\`O\\}", "&#x00D2;");
901     XML_CHARS.put("\\{\\\\\\`u\\}", "&#x00F9;");
902     XML_CHARS.put("\\{\\\\\\`U\\}", "&#x00D9;");
903     XML_CHARS.put("\\{\\\\\\'e\\}", "&#x00E9;");
904     XML_CHARS.put("\\{\\\\\\'E\\}", "&#x00C9;");
905     XML_CHARS.put("\\{\\\\\\'i\\}", "&#x00ED;");
906     XML_CHARS.put("\\{\\\\\\'I\\}", "&#x00CD;");
907     XML_CHARS.put("\\{\\\\\\'o\\}", "&#x00F3;");
908     XML_CHARS.put("\\{\\\\\\'O\\}", "&#x00D3;");
909     XML_CHARS.put("\\{\\\\\\'u\\}", "&#x00FA;");
910     XML_CHARS.put("\\{\\\\\\'U\\}", "&#x00DA;");
911     XML_CHARS.put("\\{\\\\\\'a\\}", "&#x00E1;");
912     XML_CHARS.put("\\{\\\\\\'A\\}", "&#x00C1;");
913
914     XML_CHARS.put("\\{\\\\\\^a\\}", "&#x00F4;");
915     XML_CHARS.put("\\{\\\\\\^A\\}", "&#x00D4;");
916     XML_CHARS.put("\\{\\\\\\^o\\}", "&#x00F4;");
917     XML_CHARS.put("\\{\\\\\\^O\\}", "&#x00D4;");
918     XML_CHARS.put("\\{\\\\\\^u\\}", "&#x00F9;");
919     XML_CHARS.put("\\{\\\\\\^U\\}", "&#x00D9;");
920     XML_CHARS.put("\\{\\\\\\^e\\}", "&#x00EA;");
921     XML_CHARS.put("\\{\\\\\\^E\\}", "&#x00CA;");
922     XML_CHARS.put("\\{\\\\\\^i\\}", "&#x00EE;");
923     XML_CHARS.put("\\{\\\\\\^I\\}", "&#x00CE;");
924     XML_CHARS.put("\\{\\\\\\~o\\}", "&#x00F5;");
925     XML_CHARS.put("\\{\\\\\\~O\\}", "&#x00D5;");
926     XML_CHARS.put("\\{\\\\\\~n\\}", "&#x00F1;");
927     XML_CHARS.put("\\{\\\\\\~N\\}", "&#x00D1;");
928     XML_CHARS.put("\\{\\\\\\~a\\}", "&#x00E3;");
929     XML_CHARS.put("\\{\\\\\\~A\\}", "&#x00C3;");
930
931     ASCII2XML_CHARS.put("<", "&lt;");
932     ASCII2XML_CHARS.put("\"", "&quot;");
933     ASCII2XML_CHARS.put(">", "&gt;");
934
935
936     UNICODE_CHARS.put("\u00C0", "A");
937     UNICODE_CHARS.put("\u00C1", "A");
938     UNICODE_CHARS.put("\u00C2", "A");
939     UNICODE_CHARS.put("\u00C3", "A");
940     UNICODE_CHARS.put("\u00C4", "A");
941     UNICODE_CHARS.put("\u00C5", "Aa");
942     UNICODE_CHARS.put("\u00C6", "Ae");
943     UNICODE_CHARS.put("\u00C7", "C");
944     UNICODE_CHARS.put("\u00C8", "E");
945     UNICODE_CHARS.put("\u00C9", "E");
946     UNICODE_CHARS.put("\u00CA", "E");
947     UNICODE_CHARS.put("\u00CB", "E");
948     UNICODE_CHARS.put("\u00CC", "I");
949     UNICODE_CHARS.put("\u00CD", "I");
950     UNICODE_CHARS.put("\u00CE", "I");
951     UNICODE_CHARS.put("\u00CF", "I");
952     UNICODE_CHARS.put("\u00D0", "D");
953     UNICODE_CHARS.put("\u00D1", "N");
954     UNICODE_CHARS.put("\u00D2", "O");
955     UNICODE_CHARS.put("\u00D3", "O");
956     UNICODE_CHARS.put("\u00D4", "O");
957     UNICODE_CHARS.put("\u00D5", "O");
958     UNICODE_CHARS.put("\u00D6", "Oe");
959     UNICODE_CHARS.put("\u00D8", "Oe");
960     UNICODE_CHARS.put("\u00D9", "U");
961     UNICODE_CHARS.put("\u00DA", "U");
962     UNICODE_CHARS.put("\u00DB", "U");
963     UNICODE_CHARS.put("\u00DC", "Ue"); // U umlaut ..
964     UNICODE_CHARS.put("\u00DD", "Y");
965     UNICODE_CHARS.put("\u00DF", "ss");
966     UNICODE_CHARS.put("\u00E0", "a");
967     UNICODE_CHARS.put("\u00E1", "a");
968     UNICODE_CHARS.put("\u00E2", "a");
969     UNICODE_CHARS.put("\u00E3", "a");
970     UNICODE_CHARS.put("\u00E4", "ae");
971     UNICODE_CHARS.put("\u00E5", "aa");
972     UNICODE_CHARS.put("\u00E6", "ae");
973     UNICODE_CHARS.put("\u00E7", "c");
974     UNICODE_CHARS.put("\u00E8", "e");
975     UNICODE_CHARS.put("\u00E9", "e");
976     UNICODE_CHARS.put("\u00EA", "e");
977     UNICODE_CHARS.put("\u00EB", "e");
978     UNICODE_CHARS.put("\u00EC", "i");
979     UNICODE_CHARS.put("\u00ED", "i");
980     UNICODE_CHARS.put("\u00EE", "i");
981     UNICODE_CHARS.put("\u00EF", "i");
982     UNICODE_CHARS.put("\u00F0", "o");
983     UNICODE_CHARS.put("\u00F1", "n");
984     UNICODE_CHARS.put("\u00F2", "o");
985     UNICODE_CHARS.put("\u00F3", "o");
986     UNICODE_CHARS.put("\u00F4", "o");
987     UNICODE_CHARS.put("\u00F5", "o");
988     UNICODE_CHARS.put("\u00F6", "oe");
989     UNICODE_CHARS.put("\u00F8", "oe");
990     UNICODE_CHARS.put("\u00F9", "u");
991     UNICODE_CHARS.put("\u00FA", "u");
992     UNICODE_CHARS.put("\u00FB", "u");
993     UNICODE_CHARS.put("\u00FC", "ue"); // u umlaut...
994     UNICODE_CHARS.put("\u00FD", "y");
995     UNICODE_CHARS.put("\u00FF", "y");
996     UNICODE_CHARS.put("\u0100", "A");
997     UNICODE_CHARS.put("\u0101", "a");
998     UNICODE_CHARS.put("\u0102", "A");
999     UNICODE_CHARS.put("\u0103", "a");
1000     UNICODE_CHARS.put("\u0104", "A");
1001     UNICODE_CHARS.put("\u0105", "a");
1002     UNICODE_CHARS.put("\u0106", "C");
1003     UNICODE_CHARS.put("\u0107", "c");
1004     UNICODE_CHARS.put("\u0108", "C");
1005     UNICODE_CHARS.put("\u0109", "c");
1006     UNICODE_CHARS.put("\u010A", "C");
1007     UNICODE_CHARS.put("\u010B", "c");
1008     UNICODE_CHARS.put("\u010C", "C");
1009     UNICODE_CHARS.put("\u010D", "c");
1010     UNICODE_CHARS.put("\u010E", "D");
1011     UNICODE_CHARS.put("\u010F", "d");
1012     UNICODE_CHARS.put("\u0110", "D");
1013     UNICODE_CHARS.put("\u0111", "d");
1014     UNICODE_CHARS.put("\u0112", "E");
1015     UNICODE_CHARS.put("\u0113", "e");
1016     UNICODE_CHARS.put("\u0114", "E");
1017     UNICODE_CHARS.put("\u0115", "e");
1018     UNICODE_CHARS.put("\u0116", "E");
1019     UNICODE_CHARS.put("\u0117", "e");
1020     UNICODE_CHARS.put("\u0118", "E");
1021     UNICODE_CHARS.put("\u0119", "e");
1022     UNICODE_CHARS.put("\u011A", "E");
1023     UNICODE_CHARS.put("\u011B", "e");
1024     UNICODE_CHARS.put("\u011C", "G");
1025     UNICODE_CHARS.put("\u011D", "g");
1026     UNICODE_CHARS.put("\u011E", "G");
1027     UNICODE_CHARS.put("\u011F", "g");
1028     UNICODE_CHARS.put("\u0120", "G");
1029     UNICODE_CHARS.put("\u0121", "g");
1030     UNICODE_CHARS.put("\u0122", "G");
1031     UNICODE_CHARS.put("\u0123", "g");
1032     UNICODE_CHARS.put("\u0124", "H");
1033     UNICODE_CHARS.put("\u0125", "h");
1034     UNICODE_CHARS.put("\u0127", "h");
1035     UNICODE_CHARS.put("\u0128", "I");
1036     UNICODE_CHARS.put("\u0129", "i");
1037     UNICODE_CHARS.put("\u012A", "I");
1038     UNICODE_CHARS.put("\u012B", "i");
1039     UNICODE_CHARS.put("\u012C", "I");
1040     UNICODE_CHARS.put("\u012D", "i");
1041     //UNICODE_CHARS.put("\u0100", "");
1042
1043     RTFCHARS.put("`a", "\\'e0");
1044     RTFCHARS.put("`e", "\\'e8");
1045     RTFCHARS.put("`i", "\\'ec");
1046     RTFCHARS.put("`o", "\\'f2");
1047     RTFCHARS.put("`u", "\\'f9");
1048     RTFCHARS.put("?a", "\\'e1");
1049     RTFCHARS.put("?e", "\\'e9");
1050     RTFCHARS.put("?i", "\\'ed");
1051     RTFCHARS.put("?o", "\\'f3");
1052     RTFCHARS.put("?u", "\\'fa");
1053     RTFCHARS.put("^a", "\\'e2");
1054     RTFCHARS.put("^e", "\\'ea");
1055     RTFCHARS.put("^i", "\\'ee");
1056     RTFCHARS.put("^o", "\\'f4");
1057     RTFCHARS.put("^u", "\\'fa");
1058     RTFCHARS.put("\"a", "\\'e4");
1059     RTFCHARS.put("\"e", "\\'eb");
1060     RTFCHARS.put("\"i", "\\'ef");
1061     RTFCHARS.put("\"o", "\\'f6");
1062     RTFCHARS.put("\"u", "\\uc0\\u252");
1063     RTFCHARS.put("~n", "\\'f1");
1064     RTFCHARS.put("`A", "\\'c0");
1065     RTFCHARS.put("`E", "\\'c8");
1066     RTFCHARS.put("`I", "\\'cc");
1067     RTFCHARS.put("`O", "\\'d2");
1068     RTFCHARS.put("`U", "\\'d9");
1069     RTFCHARS.put("?A", "\\'c1");
1070     RTFCHARS.put("?E", "\\'c9");
1071     RTFCHARS.put("?I", "\\'cd");
1072     RTFCHARS.put("?O", "\\'d3");
1073     RTFCHARS.put("?U", "\\'da");
1074     RTFCHARS.put("^A", "\\'c2");
1075     RTFCHARS.put("^E", "\\'ca");
1076     RTFCHARS.put("^I", "\\'ce");
1077     RTFCHARS.put("^O", "\\'d4");
1078     RTFCHARS.put("^U", "\\'db");
1079     RTFCHARS.put("\"A", "\\'c4");
1080     RTFCHARS.put("\"E", "\\'cb");
1081     RTFCHARS.put("\"I", "\\'cf");
1082     RTFCHARS.put("\"O", "\\'d6");
1083     RTFCHARS.put("\"U", "\\'dc");
1084     // Use UNICODE characters for RTF-Chars which can not be found in the standard codepage
1085
1086     //  RTFCHARS.put("`A", "\\uc0\\u192");     // "Agrave" exists in standard codepage  
1087       RTFCHARS.put("'A", "\\uc0\\u193");     // "Aacute"
1088 //  RTFCHARS.put("^A", "\\uc0\\u194");     // "Acirc"  exists in standard codepage
1089       RTFCHARS.put("~A", "\\uc0\\u195");     // "Atilde"
1090 //  RTFCHARS.put("\"A", "\\uc0\\u196");    // "Auml"   exists in standard codepage
1091       RTFCHARS.put("AA", "\\uc0\\u197");     // "Aring"
1092       RTFCHARS.put("AE", "\\uc0\\u198");     // "AElig"
1093       RTFCHARS.put("cC", "\\uc0\\u199");     // "Ccedil"
1094 //  RTFCHARS.put("`E", "\\uc0\\u200");     // "Egrave" exists in standard codepage
1095       RTFCHARS.put("'E", "\\uc0\\u201");     // "Eacute"
1096 //  RTFCHARS.put("^E", "\\uc0\\u202");     // "Ecirc"  exists in standard codepage
1097 //  RTFCHARS.put("\"E", "\\uc0\\u203");    // "Euml"   exists in standard codepage
1098 //  RTFCHARS.put("`I", "\\uc0\\u204");     // "Igrave" exists in standard codepage
1099       RTFCHARS.put("'I", "\\uc0\\u205");     // "Iacute"
1100 //  RTFCHARS.put("^I", "\\uc0\\u206");     // "Icirc"  exists in standard codepage
1101 //  RTFCHARS.put("\"I", "\\uc0\\u207");    // "Iuml"   exists in standard codepage
1102       RTFCHARS.put("DH", "\\uc0\\u208");     // "ETH"
1103       RTFCHARS.put("~N", "\\uc0\\u209");     // "Ntilde"
1104 //  RTFCHARS.put("`O", "\\uc0\\u210");     // "Ograve" exists in standard codepage
1105       RTFCHARS.put("'O", "\\uc0\\u211");     // "Oacute"
1106 //  RTFCHARS.put("^O", "\\uc0\\u212");     // "Ocirc"  exists in standard codepage
1107       RTFCHARS.put("~O", "\\uc0\\u213");     // "Otilde"
1108 //  RTFCHARS.put("\"O", "\\uc0\\u214");    // "Ouml"   exists in standard codepage
1109       // According to ISO 8859-1 the "\times" symbol should be placed here (#215).
1110       // Omitting this, because it is a mathematical symbol.
1111       RTFCHARS.put("O", "\\uc0\\u216");      // "OSlash"
1112 //  RTFCHARS.put("`U", "\\uc0\\u217");     // "Ugrave"  exists in standard codepage
1113       RTFCHARS.put("'U", "\\uc0\\u218");     // "Uacute"
1114 //  RTFCHARS.put("^U", "\\uc0\\u219");     // "Ucirc"   exists in standard codepage
1115 //  RTFCHARS.put("\"U", "\\uc0\\u220");    // "Uuml"    exists in standard codepage
1116       RTFCHARS.put("'Y", "\\uc0\\u221");     // "Yacute"
1117       RTFCHARS.put("TH", "\\uc0\\u222");     // "THORN"
1118       RTFCHARS.put("ss", "\\uc0\\u223");     // "szlig"
1119 //  RTFCHARS.put("`a", "\\uc0\\u224");     // "agrave"  exists in standard codepage
1120       RTFCHARS.put("'a", "\\uc0\\u225");     // "aacute"
1121 //  RTFCHARS.put("^a", "\\uc0\\u226");     // "acirc"   exists in standard codepage
1122       RTFCHARS.put("~a", "\\uc0\\u227");     // "atilde"
1123 //  RTFCHARS.put("\"a", "\\uc0\\u228");    // "auml"    exists in standard codepage
1124       RTFCHARS.put("aa", "\\uc0\\u229");     // "aring"
1125       RTFCHARS.put("ae", "\\uc0\\u230");     // "aelig"
1126       RTFCHARS.put("cc", "\\uc0\\u231");     // "ccedil"
1127 //  RTFCHARS.put("`e", "\\uc0\\u232");     // "egrave"  exists in standard codepage
1128       RTFCHARS.put("'e", "\\uc0\\u233");     // "eacute"
1129 //  RTFCHARS.put("^e", "\\uc0\\u234");     // "ecirc"   exists in standard codepage
1130 //  RTFCHARS.put("\"e", "\\uc0\\u235");    // "euml"    exists in standard codepage
1131 //  RTFCHARS.put("`i", "\\uc0\\u236");     // "igrave"  exists in standard codepage
1132       RTFCHARS.put("'i", "\\uc0\\u237");     // "iacute"
1133 //  RTFCHARS.put("^i", "\\uc0\\u238");     // "icirc"   exists in standard codepage
1134 //  RTFCHARS.put("\"i", "\\uc0\\u239");    // "iuml"    exists in standard codepage
1135       RTFCHARS.put("dh", "\\uc0\\u240");     // "eth"
1136 //  RTFCHARS.put("~n", "\\uc0\\u241");     // "ntilde"  exists in standard codepage
1137 //  RTFCHARS.put("`o", "\\uc0\\u242");     // "ograve"  exists in standard codepage
1138       RTFCHARS.put("'o", "\\uc0\\u243");     // "oacute"
1139 //  RTFCHARS.put("^o", "\\uc0\\u244");     // "ocirc"   exists in standard codepage
1140       RTFCHARS.put("~o", "\\uc0\\u245");     // "otilde"
1141 //  RTFCHARS.put("\"o", "\\uc0\\u246");    // "ouml"    exists in standard codepage
1142       // According to ISO 8859-1 the "\div" symbol should be placed here (#247).
1143       // Omitting this, because it is a mathematical symbol.
1144       RTFCHARS.put("o", "\\uc0\\u248");       // "oslash"
1145 //  RTFCHARS.put("`u", "\\uc0\\u249");      // "ugrave"  exists in standard codepage
1146       RTFCHARS.put("'u", "\\uc0\\u250");      // "uacute"
1147 //  RTFCHARS.put("^u", "\\uc0\\u251");      // "ucirc"   exists in standard codepage
1148 //  RTFCHARS.put("\"u", "\\uc0\\u252");     // "uuml"    exists in standard codepage
1149       RTFCHARS.put("'y", "\\uc0\\u253");      // "yacute"
1150       RTFCHARS.put("th", "\\uc0\\u254");      // "thorn"
1151       RTFCHARS.put("\"y", "\\uc0\\u255");     // "yuml"
1152
1153       RTFCHARS.put("=A", "\\uc0\\u256");      // "Amacr"
1154       RTFCHARS.put("=a", "\\uc0\\u257");      // "amacr"
1155       RTFCHARS.put("uA", "\\uc0\\u258");      // "Abreve"
1156       RTFCHARS.put("ua", "\\uc0\\u259");      // "abreve"
1157       RTFCHARS.put("kA", "\\uc0\\u260");      // "Aogon"
1158       RTFCHARS.put("ka", "\\uc0\\u261");      // "aogon"
1159       RTFCHARS.put("'C", "\\uc0\\u262");      // "Cacute"
1160       RTFCHARS.put("'c", "\\uc0\\u263");      // "cacute"
1161       RTFCHARS.put("^C", "\\uc0\\u264");      // "Ccirc"
1162       RTFCHARS.put("^c", "\\uc0\\u265");      // "ccirc"
1163       RTFCHARS.put(".C", "\\uc0\\u266");      // "Cdot"
1164       RTFCHARS.put(".c", "\\uc0\\u267");      // "cdot"
1165       RTFCHARS.put("vC", "\\uc0\\u268");      // "Ccaron"
1166       RTFCHARS.put("vc", "\\uc0\\u269");      // "ccaron"
1167       RTFCHARS.put("vD", "\\uc0\\u270");      // "Dcaron"
1168       // Symbol #271 (d´) has no special Latex command
1169       RTFCHARS.put("DJ", "\\uc0\\u272");      // "Dstrok"
1170       RTFCHARS.put("dj", "\\uc0\\u273");      // "dstrok"
1171       RTFCHARS.put("=E", "\\uc0\\u274");      // "Emacr"
1172       RTFCHARS.put("=e", "\\uc0\\u275");      // "emacr"
1173       RTFCHARS.put("uE", "\\uc0\\u276");      // "Ebreve"
1174       RTFCHARS.put("ue", "\\uc0\\u277");      // "ebreve"
1175       RTFCHARS.put(".E", "\\uc0\\u278");      // "Edot"
1176       RTFCHARS.put(".e", "\\uc0\\u279");      // "edot"
1177       RTFCHARS.put("kE", "\\uc0\\u280");      // "Eogon"
1178       RTFCHARS.put("ke", "\\uc0\\u281");      // "eogon"
1179       RTFCHARS.put("vE", "\\uc0\\u282");      // "Ecaron"
1180       RTFCHARS.put("ve", "\\uc0\\u283");      // "ecaron"
1181       RTFCHARS.put("^G", "\\uc0\\u284");      // "Gcirc"
1182       RTFCHARS.put("^g", "\\uc0\\u285");      // "gcirc"
1183       RTFCHARS.put("uG", "\\uc0\\u286");      // "Gbreve"
1184       RTFCHARS.put("ug", "\\uc0\\u287");      // "gbreve"
1185       RTFCHARS.put(".G", "\\uc0\\u288");      // "Gdot"
1186       RTFCHARS.put(".g", "\\uc0\\u289");      // "gdot"
1187       RTFCHARS.put("cG", "\\uc0\\u290");      // "Gcedil"
1188       RTFCHARS.put("'g", "\\uc0\\u291");      // "gacute"
1189       RTFCHARS.put("^H", "\\uc0\\u292");      // "Hcirc"
1190       RTFCHARS.put("^h", "\\uc0\\u293");      // "hcirc"
1191       RTFCHARS.put("Hstrok", "\\uc0\\u294");  // "Hstrok"
1192       RTFCHARS.put("hstrok", "\\uc0\\u295");  // "hstrok"
1193       RTFCHARS.put("~I", "\\uc0\\u296");      // "Itilde"
1194       RTFCHARS.put("~i", "\\uc0\\u297");      // "itilde"
1195       RTFCHARS.put("=I", "\\uc0\\u298");      // "Imacr"
1196       RTFCHARS.put("=i", "\\uc0\\u299");      // "imacr"
1197       RTFCHARS.put("uI", "\\uc0\\u300");      // "Ibreve"
1198       RTFCHARS.put("ui", "\\uc0\\u301");      // "ibreve"
1199       RTFCHARS.put("kI", "\\uc0\\u302");      // "Iogon"
1200       RTFCHARS.put("ki", "\\uc0\\u303");      // "iogon"
1201       RTFCHARS.put(".I", "\\uc0\\u304");      // "Idot"
1202       RTFCHARS.put("i", "\\uc0\\u305");       // "inodot"
1203       // Symbol #306 (IJ) has no special Latex command
1204       // Symbol #307 (ij) has no special Latex command
1205       RTFCHARS.put("^J", "\\uc0\\u308");      // "Jcirc"
1206       RTFCHARS.put("^j", "\\uc0\\u309");      // "jcirc"
1207       RTFCHARS.put("cK", "\\uc0\\u310");      // "Kcedil"
1208       RTFCHARS.put("ck", "\\uc0\\u311");      // "kcedil"
1209       // Symbol #312 (k) has no special Latex command
1210       RTFCHARS.put("'L", "\\uc0\\u313");      // "Lacute"
1211       RTFCHARS.put("'l", "\\uc0\\u314");      // "lacute"
1212       RTFCHARS.put("cL", "\\uc0\\u315");      // "Lcedil"
1213       RTFCHARS.put("cl", "\\uc0\\u316");      // "lcedil"
1214       // Symbol #317 (L´) has no special Latex command
1215       // Symbol #318 (l´) has no special Latex command
1216       RTFCHARS.put("Lmidot", "\\uc0\\u319");  // "Lmidot"
1217       RTFCHARS.put("lmidot", "\\uc0\\u320");  // "lmidot"
1218       RTFCHARS.put("L", "\\uc0\\u321");      // "Lstrok"
1219       RTFCHARS.put("l", "\\uc0\\u322");      // "lstrok"
1220       RTFCHARS.put("'N", "\\uc0\\u323");      // "Nacute"
1221       RTFCHARS.put("'n", "\\uc0\\u324");      // "nacute"
1222       RTFCHARS.put("cN", "\\uc0\\u325");      // "Ncedil"
1223       RTFCHARS.put("cn", "\\uc0\\u326");      // "ncedil"
1224       RTFCHARS.put("vN", "\\uc0\\u327");      // "Ncaron"
1225       RTFCHARS.put("vn", "\\uc0\\u328");      // "ncaron"
1226       // Symbol #329 (´n) has no special Latex command
1227       RTFCHARS.put("NG", "\\uc0\\u330");      // "ENG"
1228       RTFCHARS.put("ng", "\\uc0\\u331");      // "eng"
1229       RTFCHARS.put("=O", "\\uc0\\u332");      // "Omacr"
1230       RTFCHARS.put("=o", "\\uc0\\u333");      // "omacr"
1231       RTFCHARS.put("uO", "\\uc0\\u334");      // "Obreve"
1232       RTFCHARS.put("uo", "\\uc0\\u335");      // "obreve"
1233       RTFCHARS.put("HO", "\\uc0\\u336");      // "Odblac"
1234       RTFCHARS.put("Ho", "\\uc0\\u337");      // "odblac"
1235       RTFCHARS.put("OE", "\\uc0\\u338");      // "OElig"
1236       RTFCHARS.put("oe", "\\uc0\\u339");      // "oelig"
1237       RTFCHARS.put("'R", "\\uc0\\u340");      // "Racute"
1238       RTFCHARS.put("'r", "\\uc0\\u341");      // "racute"
1239       RTFCHARS.put("cR", "\\uc0\\u342");      // "Rcedil"
1240       RTFCHARS.put("cr", "\\uc0\\u343");      // "rcedil"
1241       RTFCHARS.put("vR", "\\uc0\\u344");      // "Rcaron"
1242       RTFCHARS.put("vr", "\\uc0\\u345");      // "rcaron"
1243       RTFCHARS.put("'S", "\\uc0\\u346");      // "Sacute"
1244       RTFCHARS.put("'s", "\\uc0\\u347");      // "sacute"
1245       RTFCHARS.put("^S", "\\uc0\\u348");      // "Scirc"
1246       RTFCHARS.put("^s", "\\uc0\\u349");      // "scirc"
1247       RTFCHARS.put("cS", "\\uc0\\u350");      // "Scedil"
1248       RTFCHARS.put("cs", "\\uc0\\u351");      // "scedil"
1249       RTFCHARS.put("vS", "\\uc0\\u352");      // "Scaron"
1250       RTFCHARS.put("vs", "\\uc0\\u353");      // "scaron"
1251       RTFCHARS.put("cT", "\\uc0\\u354");      // "Tcedil"
1252       RTFCHARS.put("ct", "\\uc0\\u355");      // "tcedil"
1253       RTFCHARS.put("vT", "\\uc0\\u356");      // "Tcaron"
1254       // Symbol #357 (t´) has no special Latex command
1255       RTFCHARS.put("Tstrok", "\\uc0\\u358");  // "Tstrok"
1256       RTFCHARS.put("tstrok", "\\uc0\\u359");  // "tstrok"
1257       RTFCHARS.put("~U", "\\uc0\\u360");      // "Utilde"
1258       RTFCHARS.put("~u", "\\uc0\\u361");      // "utilde"
1259       RTFCHARS.put("=U", "\\uc0\\u362");      // "Umacr"
1260       RTFCHARS.put("=u", "\\uc0\\u363");      // "umacr"
1261       RTFCHARS.put("uU", "\\uc0\\u364");      // "Ubreve"
1262       RTFCHARS.put("uu", "\\uc0\\u365");      // "ubreve"
1263       RTFCHARS.put("rU", "\\uc0\\u366");      // "Uring"
1264       RTFCHARS.put("ru", "\\uc0\\u367");      // "uring"
1265       RTFCHARS.put("HU", "\\uc0\\u368");      // "Odblac"
1266       RTFCHARS.put("Hu", "\\uc0\\u369");      // "odblac"
1267       RTFCHARS.put("kU", "\\uc0\\u370");      // "Uogon"
1268       RTFCHARS.put("ku", "\\uc0\\u371");      // "uogon"
1269       RTFCHARS.put("^W", "\\uc0\\u372");      // "Wcirc"
1270       RTFCHARS.put("^w", "\\uc0\\u373");      // "wcirc"
1271       RTFCHARS.put("^Y", "\\uc0\\u374");      // "Ycirc"
1272       RTFCHARS.put("^y", "\\uc0\\u375");      // "ycirc"
1273       RTFCHARS.put("\"Y", "\\uc0\\u376");     // "Yuml"
1274       RTFCHARS.put("'Z", "\\uc0\\u377");      // "Zacute"
1275       RTFCHARS.put("'z", "\\uc0\\u378");      // "zacute"
1276       RTFCHARS.put(".Z", "\\uc0\\u379");      // "Zdot"
1277       RTFCHARS.put(".z", "\\uc0\\u380");      // "zdot"
1278       RTFCHARS.put("vZ", "\\uc0\\u381");      // "Zcaron"
1279       RTFCHARS.put("vz", "\\uc0\\u382");      // "zcaron"
1280       // Symbol #383 (f) has no special Latex command
1281
1282     //XML_CHARS.put("\\u00E1", "&#x00E1;");
1283   }
1284
1285     public static void initializeJournalNames() {
1286         journalAbbrev = new JournalAbbreviations();//"/resource/journalList.txt");
1287
1288         // Read external lists, if any (in reverse order, so the upper lists override the lower):
1289         String[] lists = prefs.getStringArray("externalJournalLists");
1290         if ((lists != null) && (lists.length > 0)) {
1291             for (int i=lists.length-1; i>=0; i--) {
1292                 try {
1293                     journalAbbrev.readJournalList(new File(lists[i]));
1294                 } catch (FileNotFoundException e) {
1295                     // The file couldn't be found... should we tell anyone?
1296                     Globals.logger(e.getMessage());
1297                 }
1298             }
1299         }
1300
1301         // Read personal list, if set up:
1302         if (prefs.get("personalJournalList") != null) {
1303             try {
1304                 journalAbbrev.readJournalList(new File(prefs.get("personalJournalList")));
1305             } catch (FileNotFoundException e) {
1306                 Globals.logger("Personal journal list file '"+prefs.get("personalJournalList")+
1307                     "' not found.");
1308             }
1309         }
1310
1311
1312     }
1313
1314 }