summaryrefslogtreecommitdiff
path: root/jni/iconv/lib/iso8859_2.h
blob: 9ad4d4aa5deecb21cd8c0bff11bec3370a4c264a (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
112
/*
 * 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-2
 */

static const unsigned short iso8859_2_2uni[96] = {
  /* 0xa0 */
  0x00a00x01040x02d80x01410x00a40x013d0x015a0x00a7,
  0x00a80x01600x015e0x01640x01790x00ad0x017d0x017b,
  /* 0xb0 */
  0x00b00x01050x02db0x01420x00b40x013e0x015b0x02c7,
  0x00b80x01610x015f0x01650x017a0x02dd0x017e0x017c,
  /* 0xc0 */
  0x01540x00c10x00c20x01020x00c40x01390x01060x00c7,
  0x010c0x00c90x01180x00cb0x011a0x00cd0x00ce0x010e,
  /* 0xd0 */
  0x01100x01430x01470x00d30x00d40x01500x00d60x00d7,
  0x01580x016e0x00da0x01700x00dc0x00dd0x01620x00df,
  /* 0xe0 */
  0x01550x00e10x00e20x01030x00e40x013a0x01070x00e7,
  0x010d0x00e90x01190x00eb0x011b0x00ed0x00ee0x010f,
  /* 0xf0 */
  0x01110x01440x01480x00f30x00f40x01510x00f60x00f7,
  0x01590x016f0x00fa0x01710x00fc0x00fd0x01630x02d9,
};

static int
iso8859_2_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
{
  unsigned char c = *s;
  if (c < 0xa0)
    *pwc = (ucs4_t) c;
  else
    *pwc = (ucs4_t) iso8859_2_2uni[c-0xa0];
  return 1;
}

static const unsigned char iso8859_2_page00[224] = {
  0xa00x000x000x000xa40x000x000xa7/* 0xa0-0xa7 */
  0xa80x000x000x000x000xad0x000x00/* 0xa8-0xaf */
  0xb00x000x000x000xb40x000x000x00/* 0xb0-0xb7 */
  0xb80x000x000x000x000x000x000x00/* 0xb8-0xbf */
  0x000xc10xc20x000xc40x000x000xc7/* 0xc0-0xc7 */
  0x000xc90x000xcb0x000xcd0xce0x00/* 0xc8-0xcf */
  0x000x000x000xd30xd40x000xd60xd7/* 0xd0-0xd7 */
  0x000x000xda0x000xdc0xdd0x000xdf/* 0xd8-0xdf */
  0x000xe10xe20x000xe40x000x000xe7/* 0xe0-0xe7 */
  0x000xe90x000xeb0x000xed0xee0x00/* 0xe8-0xef */
  0x000x000x000xf30xf40x000xf60xf7/* 0xf0-0xf7 */
  0x000x000xfa0x000xfc0xfd0x000x00/* 0xf8-0xff */
  /* 0x0100 */
  0x000x000xc30xe30xa10xb10xc60xe6/* 0x00-0x07 */
  0x000x000x000x000xc80xe80xcf0xef/* 0x08-0x0f */
  0xd00xf00x000x000x000x000x000x00/* 0x10-0x17 */
  0xca0xea0xcc0xec0x000x000x000x00/* 0x18-0x1f */
  0x000x000x000x000x000x000x000x00/* 0x20-0x27 */
  0x000x000x000x000x000x000x000x00/* 0x28-0x2f */
  0x000x000x000x000x000x000x000x00/* 0x30-0x37 */
  0x000xc50xe50x000x000xa50xb50x00/* 0x38-0x3f */
  0x000xa30xb30xd10xf10x000x000xd2/* 0x40-0x47 */
  0xf20x000x000x000x000x000x000x00/* 0x48-0x4f */
  0xd50xf50x000x000xc00xe00x000x00/* 0x50-0x57 */
  0xd80xf80xa60xb60x000x000xaa0xba/* 0x58-0x5f */
  0xa90xb90xde0xfe0xab0xbb0x000x00/* 0x60-0x67 */
  0x000x000x000x000x000x000xd90xf9/* 0x68-0x6f */
  0xdb0xfb0x000x000x000x000x000x00/* 0x70-0x77 */
  0x000xac0xbc0xaf0xbf0xae0xbe0x00/* 0x78-0x7f */
};
static const unsigned char iso8859_2_page02[32] = {
  0x000x000x000x000x000x000x000xb7/* 0xc0-0xc7 */
  0x000x000x000x000x000x000x000x00/* 0xc8-0xcf */
  0x000x000x000x000x000x000x000x00/* 0xd0-0xd7 */
  0xa20xff0x000xb20x000xbd0x000x00/* 0xd8-0xdf */
};

static int
iso8859_2_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 < 0x0180)
    c = iso8859_2_page00[wc-0x00a0];
  else if (wc >= 0x02c0 && wc < 0x02e0)
    c = iso8859_2_page02[wc-0x02c0];
  if (c != 0) {
    *r = c;
    return 1;
  }
  return RET_ILUNI;
}