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

/*
 * CP1124
 */

static const unsigned short cp1124_2uni[96] = {
  /* 0xa0 */
  0x00a00x04010x04020x04900x04040x04050x04060x0407,
  0x04080x04090x040a0x040b0x040c0x00ad0x040e0x040f,
  /* 0xb0 */
  0x04100x04110x04120x04130x04140x04150x04160x0417,
  0x04180x04190x041a0x041b0x041c0x041d0x041e0x041f,
  /* 0xc0 */
  0x04200x04210x04220x04230x04240x04250x04260x0427,
  0x04280x04290x042a0x042b0x042c0x042d0x042e0x042f,
  /* 0xd0 */
  0x04300x04310x04320x04330x04340x04350x04360x0437,
  0x04380x04390x043a0x043b0x043c0x043d0x043e0x043f,
  /* 0xe0 */
  0x04400x04410x04420x04430x04440x04450x04460x0447,
  0x04480x04490x044a0x044b0x044c0x044d0x044e0x044f,
  /* 0xf0 */
  0x21160x04510x04520x04910x04540x04550x04560x0457,
  0x04580x04590x045a0x045b0x045c0x00a70x045e0x045f,
};

static int
cp1124_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) cp1124_2uni[c-0xa0];
  return 1;
}

static const unsigned char cp1124_page00[16] = {
  0xa00x000x000x000x000x000x000xfd/* 0xa0-0xa7 */
  0x000x000x000x000x000xad0x000x00/* 0xa8-0xaf */
};
static const unsigned char cp1124_page04[152] = {
  0x000xa10xa20x000xa40xa50xa60xa7/* 0x00-0x07 */
  0xa80xa90xaa0xab0xac0x000xae0xaf/* 0x08-0x0f */
  0xb00xb10xb20xb30xb40xb50xb60xb7/* 0x10-0x17 */
  0xb80xb90xba0xbb0xbc0xbd0xbe0xbf/* 0x18-0x1f */
  0xc00xc10xc20xc30xc40xc50xc60xc7/* 0x20-0x27 */
  0xc80xc90xca0xcb0xcc0xcd0xce0xcf/* 0x28-0x2f */
  0xd00xd10xd20xd30xd40xd50xd60xd7/* 0x30-0x37 */
  0xd80xd90xda0xdb0xdc0xdd0xde0xdf/* 0x38-0x3f */
  0xe00xe10xe20xe30xe40xe50xe60xe7/* 0x40-0x47 */
  0xe80xe90xea0xeb0xec0xed0xee0xef/* 0x48-0x4f */
  0x000xf10xf20x000xf40xf50xf60xf7/* 0x50-0x57 */
  0xf80xf90xfa0xfb0xfc0x000xfe0xff/* 0x58-0x5f */
  0x000x000x000x000x000x000x000x00/* 0x60-0x67 */
  0x000x000x000x000x000x000x000x00/* 0x68-0x6f */
  0x000x000x000x000x000x000x000x00/* 0x70-0x77 */
  0x000x000x000x000x000x000x000x00/* 0x78-0x7f */
  0x000x000x000x000x000x000x000x00/* 0x80-0x87 */
  0x000x000x000x000x000x000x000x00/* 0x88-0x8f */
  0xa30xf30x000x000x000x000x000x00/* 0x90-0x97 */
};

static int
cp1124_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 = cp1124_page00[wc-0x00a0];
  else if (wc >= 0x0400 && wc < 0x0498)
    c = cp1124_page04[wc-0x0400];
  else if (wc == 0x2116)
    c = 0xf0;
  if (c != 0) {
    *r = c;
    return 1;
  }
  return RET_ILUNI;
}