summaryrefslogtreecommitdiff
path: root/jni/iconv/lib/cp1125.h
blob: 802f0742d6c7baceda588824979886efaf52d6c7 (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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*
 * 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.
 */

/*
 * CP1125
 */

static const unsigned short cp1125_2uni[80] = {
  /* 0xb0 */
  0x25910x25920x25930x25020x25240x25610x25620x2556,
  0x25550x25630x25510x25570x255d0x255c0x255b0x2510,
  /* 0xc0 */
  0x25140x25340x252c0x251c0x25000x253c0x255e0x255f,
  0x255a0x25540x25690x25660x25600x25500x256c0x2567,
  /* 0xd0 */
  0x25680x25640x25650x25590x25580x25520x25530x256b,
  0x256a0x25180x250c0x25880x25840x258c0x25900x2580,
  /* 0xe0 */
  0x04400x04410x04420x04430x04440x04450x04460x0447,
  0x04480x04490x044a0x044b0x044c0x044d0x044e0x044f,
  /* 0xf0 */
  0x04010x04510x04900x04910x04040x04540x04060x0456,
  0x04070x04570x00b70x221a0x21160x00a40x25a00x00a0,
};

static int
cp1125_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
{
  unsigned char c = *s;
  if (c < 0x80)
    *pwc = (ucs4_t) c;
  else if (c < 0xb0)
    *pwc = (ucs4_t) c + 0x0390;
  else
    *pwc = (ucs4_t) cp1125_2uni[c-0xb0];
  return 1;
}

static const unsigned char cp1125_page00[24] = {
  0xff0x000x000x000xfd0x000x000x00/* 0xa0-0xa7 */
  0x000x000x000x000x000x000x000x00/* 0xa8-0xaf */
  0x000x000x000x000x000x000x000xfa/* 0xb0-0xb7 */
};
static const unsigned char cp1125_page04[152] = {
  0x000xf00x000x000xf40x000xf60xf8/* 0x00-0x07 */
  0x000x000x000x000x000x000x000x00/* 0x08-0x0f */
  0x800x810x820x830x840x850x860x87/* 0x10-0x17 */
  0x880x890x8a0x8b0x8c0x8d0x8e0x8f/* 0x18-0x1f */
  0x900x910x920x930x940x950x960x97/* 0x20-0x27 */
  0x980x990x9a0x9b0x9c0x9d0x9e0x9f/* 0x28-0x2f */
  0xa00xa10xa20xa30xa40xa50xa60xa7/* 0x30-0x37 */
  0xa80xa90xaa0xab0xac0xad0xae0xaf/* 0x38-0x3f */
  0xe00xe10xe20xe30xe40xe50xe60xe7/* 0x40-0x47 */
  0xe80xe90xea0xeb0xec0xed0xee0xef/* 0x48-0x4f */
  0x000xf10x000x000xf50x000xf70xf9/* 0x50-0x57 */
  0x000x000x000x000x000x000x000x00/* 0x58-0x5f */
  0x000x000x000x000x000x000x000x00/* 0x60-0x67 */
  0x000x000x000x000x000x000x000x00/* 0x68-0x6f */
  0x000x000x000x000x000x000x000x00/* 0x70-0x77 */
  0x000x000x000x000x000x000x000x00/* 0x78-0x7f */
  0x000x000x000x000x000x000x000x00/* 0x80-0x87 */
  0x000x000x000x000x000x000x000x00/* 0x88-0x8f */
  0xf20xf30x000x000x000x000x000x00/* 0x90-0x97 */
};
static const unsigned char cp1125_page25[168] = {
  0xc40x000xb30x000x000x000x000x00/* 0x00-0x07 */
  0x000x000x000x000xda0x000x000x00/* 0x08-0x0f */
  0xbf0x000x000x000xc00x000x000x00/* 0x10-0x17 */
  0xd90x000x000x000xc30x000x000x00/* 0x18-0x1f */
  0x000x000x000x000xb40x000x000x00/* 0x20-0x27 */
  0x000x000x000x000xc20x000x000x00/* 0x28-0x2f */
  0x000x000x000x000xc10x000x000x00/* 0x30-0x37 */
  0x000x000x000x000xc50x000x000x00/* 0x38-0x3f */
  0x000x000x000x000x000x000x000x00/* 0x40-0x47 */
  0x000x000x000x000x000x000x000x00/* 0x48-0x4f */
  0xcd0xba0xd50xd60xc90xb80xb70xbb/* 0x50-0x57 */
  0xd40xd30xc80xbe0xbd0xbc0xc60xc7/* 0x58-0x5f */
  0xcc0xb50xb60xb90xd10xd20xcb0xcf/* 0x60-0x67 */
  0xd00xca0xd80xd70xce0x000x000x00/* 0x68-0x6f */
  0x000x000x000x000x000x000x000x00/* 0x70-0x77 */
  0x000x000x000x000x000x000x000x00/* 0x78-0x7f */
  0xdf0x000x000x000xdc0x000x000x00/* 0x80-0x87 */
  0xdb0x000x000x000xdd0x000x000x00/* 0x88-0x8f */
  0xde0xb00xb10xb20x000x000x000x00/* 0x90-0x97 */
  0x000x000x000x000x000x000x000x00/* 0x98-0x9f */
  0xfe0x000x000x000x000x000x000x00/* 0xa0-0xa7 */
};

static int
cp1125_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
{
  unsigned char c = 0;
  if (wc < 0x0080) {
    *r = wc;
    return 1;
  }
  else if (wc >= 0x00a0 && wc < 0x00b8)
    c = cp1125_page00[wc-0x00a0];
  else if (wc >= 0x0400 && wc < 0x0498)
    c = cp1125_page04[wc-0x0400];
  else if (wc == 0x2116)
    c = 0xfc;
  else if (wc == 0x221a)
    c = 0xfb;
  else if (wc >= 0x2500 && wc < 0x25a8)
    c = cp1125_page25[wc-0x2500];
  if (c != 0) {
    *r = c;
    return 1;
  }
  return RET_ILUNI;
}