~ubuntu-branches/ubuntu/saucy/kakasi/saucy

« back to all changes in this revision

Viewing changes to src/ee2.c

  • Committer: Bazaar Package Importer
  • Author(s): Keita Maehara
  • Date: 2001-12-25 23:18:48 UTC
  • Revision ID: james.westby@ubuntu.com-20011225231848-oiu2kbbhoq80w774
Tags: upstream-2.3.4
ImportĀ upstreamĀ versionĀ 2.3.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * KAKASI (Kanji Kana Simple inversion program)
 
3
 * $Id: ee2.c,v 1.3 2001/01/16 07:51:47 rug Exp $
 
4
 * Copyright (C) 1992
 
5
 * Hironobu Takahashi (takahasi@tiny.or.jp)
 
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 versions 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 KAKASI, see the file COPYING.  If not, write to the Free
 
19
 * Software Foundation Inc., 59 Temple Place - Suite 330, Boston, MA
 
20
 * 02111-1307, USA.
 
21
 */
 
22
 
 
23
#ifdef HAVE_CONFIG_H
 
24
# include <config.h>
 
25
#endif
 
26
 
 
27
#include "kakasi.h"
 
28
 
 
29
static void
 
30
E2alphabet_copy(n, str, type)
 
31
     Character *n;
 
32
     char *str;
 
33
     int type;
 
34
{
 
35
    int i;
 
36
 
 
37
    for (i = 0; str[i] != '\0'; ++ i) {
 
38
        n[i].type = type;
 
39
        n[i].c1 = str[i];
 
40
    }
 
41
    n[i].type = OTHER;
 
42
    n[i].c1 = 0;
 
43
    n[i].c2 = 0;
 
44
}
 
45
 
 
46
static int
 
47
E2alphabet(c, n, type)
 
48
     Character *c;
 
49
     Character *n;
 
50
     int type;
 
51
{
 
52
    static char E2alphabet_a1table[94][12] = {
 
53
        " ",",",".",",",".",".",":",";","?","!","\"","(maru)","'","`","..","~",
 
54
        "~","_","(kurikaesi)","(kurikaesi)","(kurikaesi)","(kurikaesi)","(kurikaesi)",
 
55
        "(kurikaesi)","(kurikaesi)","sime","(maru)","^","-","-","/","\\","~","||",
 
56
        "|","...","..","`","'","\"","\"","(",")","[","]","[","]","{","}","<",">",
 
57
        "<<",">>","(",")","(",")","(",")","+","-","+-","X","/","=","!=","<",">",
 
58
        "<=",">=","(kigou)","...","(osu)","(mesu)","(do)","'","\"","(Sessi)","\\",
 
59
        "$","(cent)","(fran)","%","#","&","*","@","(setu)","(hosi)","(hosi)","(maru)",
 
60
        "(maru)","(maru)","(diamond)" };
 
61
    static char E2greek_table[56][8] = {
 
62
        "Alpha", "Beta", "Gamma", "Delta", "Epsilon", "Zeta", "Eta", "Theta",
 
63
        "Iota", "Kappa", "Lambda", "Mu", "Nu", "Xi", "Omicron", "Pi", "Rho",
 
64
        "Sigma", "Tau", "Upsilon", "Phi", "Chi", "Psi", "Omega", 
 
65
        "", "", "", "", "", "", "", "", 
 
66
        "alpha", "beta", "gamma", "delta", "epsilon", "zeta", "eta", "theta",
 
67
        "iota", "kappa", "lambda", "mu", "nu", "xi", "omicron", "pi", "rho",
 
68
        "sigma", "tau", "upsilon", "phi", "chi", "psi", "omega"};
 
69
 
 
70
    switch(c[0].c1) { /* Management is divided into every classification. */
 
71
      case 0xa1: /* It changes by using the table because sign/others are mixed in the first district. */
 
72
        if ((0xa1 <= c[0].c2) && (c[0].c2 < 0xa1 + 94)) {
 
73
            E2alphabet_copy(n, E2alphabet_a1table[c[0].c2-0xa1], type);
 
74
            return 1;
 
75
        } else {
 
76
            E2alphabet_copy(n, "??", type);
 
77
            return 1;
 
78
        }
 
79
      case 0xa2: /* A sign is contained in the second district. Because it is troublesome, (kigou) is completely taken. */
 
80
        E2alphabet_copy(n, "(kigou)", type);
 
81
        return 1;
 
82
      case 0xa3: /* Ascii and number are contained in the third district. */
 
83
        n[0].type = type;
 
84
        n[0].c1 = c[0].c2 & 0x7f; /* This is corner-cutting. The character which isn't defined is done somehow. */
 
85
        n[1].type = OTHER;
 
86
        n[2].c1 = '\0';
 
87
#ifdef WAKATIGAKI
 
88
        n[0].c2 = '\0';
 
89
        n[1].c1 = '\0';
 
90
        n[1].c2 = '\0';
 
91
        n[2].c2 = '\0';
 
92
#endif /* WAKATIGAKI */
 
93
        return 1;
 
94
      case 0xa4: /* HIRAGANA */
 
95
        return H2rom(c, n, type);
 
96
      case 0xa5: /* KATAKANA */
 
97
        return K2rom(c, n, type);
 
98
      case 0xa6: /* The sixth district is Greek. */
 
99
        if ((0xa1 <= c[0].c2) && (c[0].c2 < 0xa1 + 56)) {
 
100
            E2alphabet_copy(n, E2greek_table[c[0].c2-0xa1], type);
 
101
            return 1;
 
102
        } else {
 
103
            E2alphabet_copy(n, "??", type);
 
104
            return 1;
 
105
        }
 
106
      case 0xa7: /* The seventh district is Russian. */
 
107
        E2alphabet_copy(n, "(Russia)", type);
 
108
        return 1;
 
109
      default:   /* The eighth district line base settlement. You have only to read it except for that with what. */
 
110
        E2alphabet_copy(n, "??", type);
 
111
        return 1;
 
112
    }
 
113
}
 
114
 
 
115
int
 
116
E2a(c, n)
 
117
     Character *c;
 
118
     Character *n;
 
119
{
 
120
    return E2alphabet(c, n, ASCII);
 
121
}
 
122
 
 
123
int
 
124
E2j(c, n)
 
125
     Character *c;
 
126
     Character *n;
 
127
{
 
128
    return E2alphabet(c, n, JISROMAN);
 
129
}