File: lat1html.c

package info (click to toggle)
recode 3.4.1-11
  • links: PTS
  • area: main
  • in suites: slink
  • size: 1,560 kB
  • ctags: 622
  • sloc: ansic: 10,572; perl: 339; makefile: 317; lisp: 243; sh: 173; lex: 165; awk: 127; sed: 10
file content (179 lines) | stat: -rw-r--r-- 4,430 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/* Conversion of files between different charsets and usages.
   Copyright (C) 1990, 1993 Free Software Foundation, Inc.
   Francois Pinard <pinard@iro.umontreal.ca>, 1988.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2, or (at your option)
   any later version.

   This program is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include "recode.h"

struct translation
  {
    int code;			/* code being translated */
    const char *string;		/* translation string */
  };

static struct translation diacritic_translations [] =
  {
    {160, "&nbsp;"},
    {161, "&iexcl;"},
    {162, "&cent;"},
    {163, "&pound;"},
    {164, "&curren;"},
    {165, "&yen;"},
    {166, "&brvbar;"},
    {167, "&sect;"},
    {168, "&uml;"},
    {169, "&copy;"},
    {170, "&ordf;"},
    {171, "&laquo;"},
    {172, "&not;"},
    {173, "&shy;"},
    {174, "&reg;"},
    {175, "&hibar;"},
    {176, "&deg;"},
    {177, "&plusmn;"},
    {178, "&sup2;"},
    {179, "&sup3;"},
    {180, "&acute;"},
    {181, "&micro;"},
    {182, "&para;"},
    {183, "&middot;"},
    {184, "&cedil;"},
    {185, "&sup1;"},
    {186, "&ordm;"},
    {187, "&raquo;"},
    {188, "&frac14;"},
    {189, "&frac12;"},
    {190, "&frac34;"},
    {191, "&iquest;"},
    {192, "&Agrave;"},
    {193, "&Aacute;"},
    {194, "&Acirc;"},
    {195, "&Atilde;"},
    {196, "&Auml;"},
    {197, "&Aring;"},
    {198, "&AElig;"},
    {199, "&Ccedil;"},
    {200, "&Egrave;"},
    {201, "&Eacute;"},
    {202, "&Ecirc;"},
    {203, "&Euml;"},
    {204, "&Igrave;"},
    {205, "&Iacute;"},
    {206, "&Icirc;"},
    {207, "&Iuml;"},
    {208, "&ETH;"},
    {209, "&Ntilde;"},
    {210, "&Ograve;"},
    {211, "&Oacute;"},
    {212, "&Ocirc;"},
    {213, "&Otilde;"},
    {214, "&Ouml;"},
    {215, "&times;"},
    {216, "&Oslash;"},
    {217, "&Ugrave;"},
    {218, "&Uacute;"},
    {219, "&Ucirc;"},
    {220, "&Uuml;"},
    {221, "&Yacute;"},
    {222, "&THORN;"},
    {223, "&szlig;"},
    {224, "&agrave;"},
    {225, "&aacute;"},
    {226, "&acirc;"},
    {227, "&atilde;"},
    {228, "&auml;"},
    {229, "&aring;"},
    {230, "&aelig;"},
    {231, "&ccedil;"},
    {232, "&egrave;"},
    {233, "&eacute;"},
    {234, "&ecirc;"},
    {235, "&euml;"},
    {236, "&igrave;"},
    {237, "&iacute;"},
    {238, "&icirc;"},
    {239, "&iuml;"},
    {240, "&eth;"},
    {241, "&ntilde;"},
    {242, "&ograve;"},
    {243, "&oacute;"},
    {244, "&ocirc;"},
    {245, "&otilde;"},
    {246, "&ouml;"},
    {247, "&divide;"},
    {248, "&oslash;"},
    {249, "&ugrave;"},
    {250, "&uacute;"},
    {251, "&ucirc;"},
    {252, "&uuml;"},
    {253, "&yacute;"},
    {254, "&thorn;"},
    {255, "&yuml;"},
    {0, NULL}
  };

static struct translation const other_translations [] =
  {
    {34, "&quot;"},
    {38, "&amp;"},
    {60, "&lt;"},
    {62, "&gt;"},
    {0, NULL}
  };

static void
init_latin1_html (STEP *step)
{
  char *pool;
  const char **table;
  int counter;
  struct translation const *cursor;

  table = (const char **) xmalloc (256 * sizeof (char *) + 256);
  pool = (char *) (table + 256);

  for (counter = 0; counter < 128; counter++)
    {
      pool[2 * counter] = counter;
      pool[2 * counter + 1] = '\0';
      table[counter] = pool + 2 * counter;
    }
  for (counter = 128; counter < 256; counter++)
    table[counter] = NULL;
  for (cursor = diacritic_translations; cursor->code; cursor++)
    table[cursor->code] = cursor->string;

  if (!diacritics_only)
    for (cursor = other_translations; cursor->code; cursor++)
      table[cursor->code] = cursor->string;

  step->one_to_many = table;
}

void
module_latin1_html (void)
{
  declare_alias ("HTML", "ISO_8879:1986");
  declare_step ("latin1", "HTML", ONE_TO_MANY, init_latin1_html,
		file_one_to_many);

  declare_alias ("entity", "HTML");
  declare_alias ("HTF", "HTML");
  declare_alias ("SGML", "HTML");
  declare_alias ("WWW", "HTML");
  declare_alias ("w3", "HTML");
}