summaryrefslogtreecommitdiff
path: root/jni/iconv/lib/iso8859_7.h
blob: 0825ef5cd9eaa365c246ec90064577b30faa3c15 (plain)
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
/*
 * Copyright (C) 1999-2004 Free Software Foundation, Inc.
 * This file is part of the GNU LIBICONV Library.
 *
 * The GNU LIBICONV Library is free software; you can redistribute it
 * and/or modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * The GNU LIBICONV Library 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with the GNU LIBICONV Library; see the file COPYING.LIB.
 * If not, write to the Free Software Foundation, Inc., 51 Franklin Street,
 * Fifth Floor, Boston, MA 02110-1301, USA.
 */

/*
 * ISO-8859-7
 */

static const unsigned short iso8859_7_2uni[96] = {
  /* 0xa0 */
  0x00a00x20180x20190x00a30x20ac0x20af0x00a60x00a7,
  0x00a80x00a90x037a0x00ab0x00ac0x00ad0xfffd0x2015,
  /* 0xb0 */
  0x00b00x00b10x00b20x00b30x03840x03850x03860x00b7,
  0x03880x03890x038a0x00bb0x038c0x00bd0x038e0x038f,
  /* 0xc0 */
  0x03900x03910x03920x03930x03940x03950x03960x0397,
  0x03980x03990x039a0x039b0x039c0x039d0x039e0x039f,
  /* 0xd0 */
  0x03a00x03a10xfffd0x03a30x03a40x03a50x03a60x03a7,
  0x03a80x03a90x03aa0x03ab0x03ac0x03ad0x03ae0x03af,
  /* 0xe0 */
  0x03b00x03b10x03b20x03b30x03b40x03b50x03b60x03b7,
  0x03b80x03b90x03ba0x03bb0x03bc0x03bd0x03be0x03bf,
  /* 0xf0 */
  0x03c00x03c10x03c20x03c30x03c40x03c50x03c60x03c7,
  0x03c80x03c90x03ca0x03cb0x03cc0x03cd0x03ce0xfffd,
};

static int
iso8859_7_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
{
  unsigned char c = *s;
  if (c < 0xa0) {
    *pwc = (ucs4_t) c;
    return 1;
  }
  else {
    unsigned short wc = iso8859_7_2uni[c-0xa0];
    if (wc != 0xfffd) {
      *pwc = (ucs4_t) wc;
      return 1;
    }
  }
  return RET_ILSEQ;
}

static const unsigned char iso8859_7_page00[32] = {
  0xa00x000x000xa30x000x000xa60xa7/* 0xa0-0xa7 */
  0xa80xa90x000xab0xac0xad0x000x00/* 0xa8-0xaf */
  0xb00xb10xb20xb30x000x000x000xb7/* 0xb0-0xb7 */
  0x000x000x000xbb0x000xbd0x000x00/* 0xb8-0xbf */
};
static const unsigned char iso8859_7_page03[88] = {
  0x000x000xaa0x000x000x000x000x00/* 0x78-0x7f */
  0x000x000x000x000xb40xb50xb60x00/* 0x80-0x87 */
  0xb80xb90xba0x000xbc0x000xbe0xbf/* 0x88-0x8f */
  0xc00xc10xc20xc30xc40xc50xc60xc7/* 0x90-0x97 */
  0xc80xc90xca0xcb0xcc0xcd0xce0xcf/* 0x98-0x9f */
  0xd00xd10x000xd30xd40xd50xd60xd7/* 0xa0-0xa7 */
  0xd80xd90xda0xdb0xdc0xdd0xde0xdf/* 0xa8-0xaf */
  0xe00xe10xe20xe30xe40xe50xe60xe7/* 0xb0-0xb7 */
  0xe80xe90xea0xeb0xec0xed0xee0xef/* 0xb8-0xbf */
  0xf00xf10xf20xf30xf40xf50xf60xf7/* 0xc0-0xc7 */
  0xf80xf90xfa0xfb0xfc0xfd0xfe0x00/* 0xc8-0xcf */
};
static const unsigned char iso8859_7_page20[16] = {
  0x000x000x000x000x000xaf0x000x00/* 0x10-0x17 */
  0xa10xa20x000x000x000x000x000x00/* 0x18-0x1f */
};

static int
iso8859_7_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
{
  unsigned char c = 0;
  if (wc < 0x00a0) {
    *r = wc;
    return 1;
  }
  else if (wc >= 0x00a0 && wc < 0x00c0)
    c = iso8859_7_page00[wc-0x00a0];
  else if (wc >= 0x0378 && wc < 0x03d0)
    c = iso8859_7_page03[wc-0x0378];
  else if (wc >= 0x2010 && wc < 0x2020)
    c = iso8859_7_page20[wc-0x2010];
  else if (wc == 0x20ac)
    c = 0xa4;
  else if (wc == 0x20af)
    c = 0xa5;
  if (c != 0) {
    *r = c;
    return 1;
  }
  return RET_ILUNI;
}