home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / gnurecod.zip / lat1html.c < prev    next >
C/C++ Source or Header  |  1994-03-19  |  4KB  |  143 lines

  1. /* Conversion of files between different charsets and usages.
  2.    Copyright (C) 1990, 1993 Free Software Foundation, Inc.
  3.    Francois Pinard <pinard@iro.umontreal.ca>, 1988.
  4.  
  5.    This program is free software; you can redistribute it and/or modify
  6.    it under the terms of the GNU General Public License as published by
  7.    the Free Software Foundation; either version 2, or (at your option)
  8.    any later version.
  9.  
  10.    This program is distributed in the hope that it will be useful, but
  11.    WITHOUT ANY WARRANTY; without even the implied warranty of
  12.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.    General Public License for more details.
  14.  
  15.    You should have received a copy of the GNU General Public License
  16.    along with this program; if not, write to the Free Software
  17.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. */
  19.  
  20. #include "recode.h"
  21.  
  22. struct translation
  23.   {
  24.     int code;            /* code being translated */
  25.     const char *string;        /* translation string */
  26.   };
  27.  
  28. static struct translation diacritic_translations [] =
  29.   {
  30.     {192, "À"},
  31.     {193, "Á"},
  32.     {194, "Âu;"},
  33.     {195, "Ã"},
  34.     {196, "&Adiaer;"},
  35.     {197, "Å"},
  36.     {198, "&AE;"},
  37.     {199, "Ç"},
  38.     {200, "È"},
  39.     {201, "É"},
  40.     {202, "Êu;"},
  41.     {203, "&Ediaer;"},
  42.     {204, "Ì"},
  43.     {205, "Í"},
  44.     {206, "Îu;"},
  45.     {207, "&Idiaer;"},
  46.     {208, "Ð"},
  47.     {209, "Ñ"},
  48.     {210, "Ò"},
  49.     {211, "Ó"},
  50.     {212, "Ôu;"},
  51.     {213, "Õ"},
  52.     {214, "&Odiaer;"},
  53.     {215, "&MULT;"},
  54.     {216, "&Ostroke;"},
  55.     {217, "Ù"},
  56.     {218, "Ú"},
  57.     {219, "Ûu;"},
  58.     {220, "&Udiaer;"},
  59.     {221, "Ý"},
  60.     {222, "Þ"},
  61.     {223, "&ssharp;"},
  62.     {224, "à"},
  63.     {225, "á"},
  64.     {226, "âu;"},
  65.     {227, "ã"},
  66.     {228, "&adiaer;"},
  67.     {229, "å"},
  68.     {230, "&ae;"},
  69.     {231, "ç"},
  70.     {232, "è"},
  71.     {233, "é"},
  72.     {234, "êu;"},
  73.     {235, "&ediaer;"},
  74.     {236, "ì"},
  75.     {237, "í"},
  76.     {238, "îu;"},
  77.     {239, "&idiaer;"},
  78.     {240, "ð"},
  79.     {241, "ñ"},
  80.     {242, "ò"},
  81.     {243, "ó"},
  82.     {244, "ôu;"},
  83.     {245, "õ"},
  84.     {246, "&odiaer;"},
  85.     {247, "&DIVIS;"},
  86.     {248, "&ostroke;"},
  87.     {249, "ù"},
  88.     {250, "ú"},
  89.     {251, "ûu;"},
  90.     {252, "&udiaer;"},
  91.     {253, "ý"},
  92.     {254, "þ"},
  93.     {255, "&ydiaer;"},
  94.     {0, NULL}
  95.   };
  96.  
  97. static struct translation const other_translations [] =
  98.   {
  99.     {38, "&"},
  100.     {60, "<"},
  101.     {62, ">"},
  102.     {0, NULL}
  103.   };
  104.  
  105. static void
  106. init_latin1_html (STEP *step)
  107. {
  108.   char *pool;
  109.   const char **table;
  110.   int counter;
  111.   struct translation const *cursor;
  112.  
  113.   table = (const char **) xmalloc (256 * sizeof (char *) + 256);
  114.   pool = (char *) (table + 256);
  115.  
  116.   for (counter = 0; counter < 128; counter++)
  117.     {
  118.       pool[2 * counter] = counter;
  119.       pool[2 * counter + 1] = '\0';
  120.       table[counter] = pool + 2 * counter;
  121.     }
  122.   for (counter = 128; counter < 256; counter++)
  123.     table[counter] = NULL;
  124.   for (cursor = diacritic_translations; cursor->code; cursor++)
  125.     table[cursor->code] = cursor->string;
  126.  
  127.   if (!diacritics_only)
  128.     for (cursor = other_translations; cursor->code; cursor++)
  129.       table[cursor->code] = cursor->string;
  130.  
  131.   step->one_to_many = table;
  132. }
  133.  
  134. void
  135. module_latin1_html (void)
  136. {
  137.   declare_step ("latin1", "HTML", ONE_TO_MANY, init_latin1_html,
  138.         file_one_to_many);
  139.  
  140.   declare_alias ("WWW", "HTML");
  141.   declare_alias ("w3", "HTML");
  142. }
  143.