summaryrefslogtreecommitdiff
path: root/jni/iconv/lib/iso8859_6.h
blob: 8d311994093e07f324d9393a0dfbd9c162340aea (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
/*
 * 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-6
 */

static const unsigned short iso8859_6_2uni[96] = {
  /* 0xa0 */
  0x00a00xfffd0xfffd0xfffd0x00a40xfffd0xfffd0xfffd,
  0xfffd0xfffd0xfffd0xfffd0x060c0x00ad0xfffd0xfffd,
  /* 0xb0 */
  0xfffd0xfffd0xfffd0xfffd0xfffd0xfffd0xfffd0xfffd,
  0xfffd0xfffd0xfffd0x061b0xfffd0xfffd0xfffd0x061f,
  /* 0xc0 */
  0xfffd0x06210x06220x06230x06240x06250x06260x0627,
  0x06280x06290x062a0x062b0x062c0x062d0x062e0x062f,
  /* 0xd0 */
  0x06300x06310x06320x06330x06340x06350x06360x0637,
  0x06380x06390x063a0xfffd0xfffd0xfffd0xfffd0xfffd,
  /* 0xe0 */
  0x06400x06410x06420x06430x06440x06450x06460x0647,
  0x06480x06490x064a0x064b0x064c0x064d0x064e0x064f,
  /* 0xf0 */
  0x06500x06510x06520xfffd0xfffd0xfffd0xfffd0xfffd,
  0xfffd0xfffd0xfffd0xfffd0xfffd0xfffd0xfffd0xfffd,
};

static int
iso8859_6_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_6_2uni[c-0xa0];
    if (wc != 0xfffd) {
      *pwc = (ucs4_t) wc;
      return 1;
    }
  }
  return RET_ILSEQ;
}

static const unsigned char iso8859_6_page00[16] = {
  0xa00x000x000x000xa40x000x000x00/* 0xa0-0xa7 */
  0x000x000x000x000x000xad0x000x00/* 0xa8-0xaf */
};
static const unsigned char iso8859_6_page06[80] = {
  0x000x000x000x000xac0x000x000x00/* 0x08-0x0f */
  0x000x000x000x000x000x000x000x00/* 0x10-0x17 */
  0x000x000x000xbb0x000x000x000xbf/* 0x18-0x1f */
  0x000xc10xc20xc30xc40xc50xc60xc7/* 0x20-0x27 */
  0xc80xc90xca0xcb0xcc0xcd0xce0xcf/* 0x28-0x2f */
  0xd00xd10xd20xd30xd40xd50xd60xd7/* 0x30-0x37 */
  0xd80xd90xda0x000x000x000x000x00/* 0x38-0x3f */
  0xe00xe10xe20xe30xe40xe50xe60xe7/* 0x40-0x47 */
  0xe80xe90xea0xeb0xec0xed0xee0xef/* 0x48-0x4f */
  0xf00xf10xf20x000x000x000x000x00/* 0x50-0x57 */
};

static int
iso8859_6_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 < 0x00b0)
    c = iso8859_6_page00[wc-0x00a0];
  else if (wc >= 0x0608 && wc < 0x0658)
    c = iso8859_6_page06[wc-0x0608];
  if (c != 0) {
    *r = c;
    return 1;
  }
  return RET_ILUNI;
}