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

/*
 * HP-ROMAN8
 */

static const unsigned short hp_roman8_2uni[96] = {
  /* 0xa0 */
  0x00a00x00c00x00c20x00c80x00ca0x00cb0x00ce0x00cf,
  0x00b40x02cb0x02c60x00a80x02dc0x00d90x00db0x20a4,
  /* 0xb0 */
  0x00af0x00dd0x00fd0x00b00x00c70x00e70x00d10x00f1,
  0x00a10x00bf0x00a40x00a30x00a50x00a70x01920x00a2,
  /* 0xc0 */
  0x00e20x00ea0x00f40x00fb0x00e10x00e90x00f30x00fa,
  0x00e00x00e80x00f20x00f90x00e40x00eb0x00f60x00fc,
  /* 0xd0 */
  0x00c50x00ee0x00d80x00c60x00e50x00ed0x00f80x00e6,
  0x00c40x00ec0x00d60x00dc0x00c90x00ef0x00df0x00d4,
  /* 0xe0 */
  0x00c10x00c30x00e30x00d00x00f00x00cd0x00cc0x00d3,
  0x00d20x00d50x00f50x01600x01610x00da0x01780x00ff,
  /* 0xf0 */
  0x00de0x00fe0x00b70x00b50x00b60x00be0x20140x00bc,
  0x00bd0x00aa0x00ba0x00ab0x25a00x00bb0x00b10xfffd,
};

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

static const unsigned char hp_roman8_page00[96] = {
  0xa00xb80xbf0xbb0xba0xbc0x000xbd/* 0xa0-0xa7 */
  0xab0x000xf90xfb0x000x000x000xb0/* 0xa8-0xaf */
  0xb30xfe0x000x000xa80xf30xf40xf2/* 0xb0-0xb7 */
  0x000x000xfa0xfd0xf70xf80xf50xb9/* 0xb8-0xbf */
  0xa10xe00xa20xe10xd80xd00xd30xb4/* 0xc0-0xc7 */
  0xa30xdc0xa40xa50xe60xe50xa60xa7/* 0xc8-0xcf */
  0xe30xb60xe80xe70xdf0xe90xda0x00/* 0xd0-0xd7 */
  0xd20xad0xed0xae0xdb0xb10xf00xde/* 0xd8-0xdf */
  0xc80xc40xc00xe20xcc0xd40xd70xb5/* 0xe0-0xe7 */
  0xc90xc50xc10xcd0xd90xd50xd10xdd/* 0xe8-0xef */
  0xe40xb70xca0xc60xc20xea0xce0x00/* 0xf0-0xf7 */
  0xd60xcb0xc70xc30xcf0xb20xf10xef/* 0xf8-0xff */
};
static const unsigned char hp_roman8_page01[56] = {
  0xeb0xec0x000x000x000x000x000x00/* 0x60-0x67 */
  0x000x000x000x000x000x000x000x00/* 0x68-0x6f */
  0x000x000x000x000x000x000x000x00/* 0x70-0x77 */
  0xee0x000x000x000x000x000x000x00/* 0x78-0x7f */
  0x000x000x000x000x000x000x000x00/* 0x80-0x87 */
  0x000x000x000x000x000x000x000x00/* 0x88-0x8f */
  0x000x000xbe0x000x000x000x000x00/* 0x90-0x97 */
};
static const unsigned char hp_roman8_page02[32] = {
  0x000x000x000x000x000x000xaa0x00/* 0xc0-0xc7 */
  0x000x000x000xa90x000x000x000x00/* 0xc8-0xcf */
  0x000x000x000x000x000x000x000x00/* 0xd0-0xd7 */
  0x000x000x000x000xac0x000x000x00/* 0xd8-0xdf */
};

static int
hp_roman8_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 < 0x0100)
    c = hp_roman8_page00[wc-0x00a0];
  else if (wc >= 0x0160 && wc < 0x0198)
    c = hp_roman8_page01[wc-0x0160];
  else if (wc >= 0x02c0 && wc < 0x02e0)
    c = hp_roman8_page02[wc-0x02c0];
  else if (wc == 0x2014)
    c = 0xf6;
  else if (wc == 0x20a4)
    c = 0xaf;
  else if (wc == 0x25a0)
    c = 0xfc;
  if (c != 0) {
    *r = c;
    return 1;
  }
  return RET_ILUNI;
}