summaryrefslogtreecommitdiff
path: root/jni/iconv/lib/iso8859_8.h
blob: 6184846ea13b5a5cfaea57259bab6e5575490ffd (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
/*
 * Copyright (C) 1999-2001 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-8
 */

static const unsigned short iso8859_8_2uni[96] = {
  /* 0xa0 */
  0x00a00xfffd0x00a20x00a30x00a40x00a50x00a60x00a7,
  0x00a80x00a90x00d70x00ab0x00ac0x00ad0x00ae0x00af,
  /* 0xb0 */
  0x00b00x00b10x00b20x00b30x00b40x00b50x00b60x00b7,
  0x00b80x00b90x00f70x00bb0x00bc0x00bd0x00be0xfffd,
  /* 0xc0 */
  0xfffd0xfffd0xfffd0xfffd0xfffd0xfffd0xfffd0xfffd,
  0xfffd0xfffd0xfffd0xfffd0xfffd0xfffd0xfffd0xfffd,
  /* 0xd0 */
  0xfffd0xfffd0xfffd0xfffd0xfffd0xfffd0xfffd0xfffd,
  0xfffd0xfffd0xfffd0xfffd0xfffd0xfffd0xfffd0x2017,
  /* 0xe0 */
  0x05d00x05d10x05d20x05d30x05d40x05d50x05d60x05d7,
  0x05d80x05d90x05da0x05db0x05dc0x05dd0x05de0x05df,
  /* 0xf0 */
  0x05e00x05e10x05e20x05e30x05e40x05e50x05e60x05e7,
  0x05e80x05e90x05ea0xfffd0xfffd0x200e0x200f0xfffd,
};

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

static const unsigned char iso8859_8_page00[88] = {
  0xa00x000xa20xa30xa40xa50xa60xa7/* 0xa0-0xa7 */
  0xa80xa90x000xab0xac0xad0xae0xaf/* 0xa8-0xaf */
  0xb00xb10xb20xb30xb40xb50xb60xb7/* 0xb0-0xb7 */
  0xb80xb90x000xbb0xbc0xbd0xbe0x00/* 0xb8-0xbf */
  0x000x000x000x000x000x000x000x00/* 0xc0-0xc7 */
  0x000x000x000x000x000x000x000x00/* 0xc8-0xcf */
  0x000x000x000x000x000x000x000xaa/* 0xd0-0xd7 */
  0x000x000x000x000x000x000x000x00/* 0xd8-0xdf */
  0x000x000x000x000x000x000x000x00/* 0xe0-0xe7 */
  0x000x000x000x000x000x000x000x00/* 0xe8-0xef */
  0x000x000x000x000x000x000x000xba/* 0xf0-0xf7 */
};
static const unsigned char iso8859_8_page05[32] = {
  0xe00xe10xe20xe30xe40xe50xe60xe7/* 0xd0-0xd7 */
  0xe80xe90xea0xeb0xec0xed0xee0xef/* 0xd8-0xdf */
  0xf00xf10xf20xf30xf40xf50xf60xf7/* 0xe0-0xe7 */
  0xf80xf90xfa0x000x000x000x000x00/* 0xe8-0xef */
};
static const unsigned char iso8859_8_page20[16] = {
  0x000x000x000x000x000x000xfd0xfe/* 0x08-0x0f */
  0x000x000x000x000x000x000x000xdf/* 0x10-0x17 */
};

static int
iso8859_8_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 < 0x00f8)
    c = iso8859_8_page00[wc-0x00a0];
  else if (wc >= 0x05d0 && wc < 0x05f0)
    c = iso8859_8_page05[wc-0x05d0];
  else if (wc >= 0x2008 && wc < 0x2018)
    c = iso8859_8_page20[wc-0x2008];
  if (c != 0) {
    *r = c;
    return 1;
  }
  return RET_ILUNI;
}