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

/*
 * CP850
 */

static const unsigned short cp850_2uni[128] = {
  /* 0x80 */
  0x00c70x00fc0x00e90x00e20x00e40x00e00x00e50x00e7,
  0x00ea0x00eb0x00e80x00ef0x00ee0x00ec0x00c40x00c5,
  /* 0x90 */
  0x00c90x00e60x00c60x00f40x00f60x00f20x00fb0x00f9,
  0x00ff0x00d60x00dc0x00f80x00a30x00d80x00d70x0192,
  /* 0xa0 */
  0x00e10x00ed0x00f30x00fa0x00f10x00d10x00aa0x00ba,
  0x00bf0x00ae0x00ac0x00bd0x00bc0x00a10x00ab0x00bb,
  /* 0xb0 */
  0x25910x25920x25930x25020x25240x00c10x00c20x00c0,
  0x00a90x25630x25510x25570x255d0x00a20x00a50x2510,
  /* 0xc0 */
  0x25140x25340x252c0x251c0x25000x253c0x00e30x00c3,
  0x255a0x25540x25690x25660x25600x25500x256c0x00a4,
  /* 0xd0 */
  0x00f00x00d00x00ca0x00cb0x00c80x01310x00cd0x00ce,
  0x00cf0x25180x250c0x25880x25840x00a60x00cc0x2580,
  /* 0xe0 */
  0x00d30x00df0x00d40x00d20x00f50x00d50x00b50x00fe,
  0x00de0x00da0x00db0x00d90x00fd0x00dd0x00af0x00b4,
  /* 0xf0 */
  0x00ad0x00b10x20170x00be0x00b60x00a70x00f70x00b8,
  0x00b00x00a80x00b70x00b90x00b30x00b20x25a00x00a0,
};

static int
cp850_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
    *pwc = (ucs4_t) cp850_2uni[c-0x80];
  return 1;
}

static const unsigned char cp850_page00[96] = {
  0xff0xad0xbd0x9c0xcf0xbe0xdd0xf5/* 0xa0-0xa7 */
  0xf90xb80xa60xae0xaa0xf00xa90xee/* 0xa8-0xaf */
  0xf80xf10xfd0xfc0xef0xe60xf40xfa/* 0xb0-0xb7 */
  0xf70xfb0xa70xaf0xac0xab0xf30xa8/* 0xb8-0xbf */
  0xb70xb50xb60xc70x8e0x8f0x920x80/* 0xc0-0xc7 */
  0xd40x900xd20xd30xde0xd60xd70xd8/* 0xc8-0xcf */
  0xd10xa50xe30xe00xe20xe50x990x9e/* 0xd0-0xd7 */
  0x9d0xeb0xe90xea0x9a0xed0xe80xe1/* 0xd8-0xdf */
  0x850xa00x830xc60x840x860x910x87/* 0xe0-0xe7 */
  0x8a0x820x880x890x8d0xa10x8c0x8b/* 0xe8-0xef */
  0xd00xa40x950xa20x930xe40x940xf6/* 0xf0-0xf7 */
  0x9b0x970xa30x960x810xec0xe70x98/* 0xf8-0xff */
};
static const unsigned char cp850_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 */
  0xcd0xba0x000x000xc90x000x000xbb/* 0x50-0x57 */
  0x000x000xc80x000x000xbc0x000x00/* 0x58-0x5f */
  0xcc0x000x000xb90x000x000xcb0x00/* 0x60-0x67 */
  0x000xca0x000x000xce0x000x000x00/* 0x68-0x6f */
  0x000x000x000x000x000x000x000x00/* 0x70-0x77 */
  0x000x000x000x000x000x000x000x00/* 0x78-0x7f */
  0xdf0x000x000x000xdc0x000x000x00/* 0x80-0x87 */
  0xdb0x000x000x000x000x000x000x00/* 0x88-0x8f */
  0x000xb00xb10xb20x000x000x000x00/* 0x90-0x97 */
  0x000x000x000x000x000x000x000x00/* 0x98-0x9f */
  0xfe0x000x000x000x000x000x000x00/* 0xa0-0xa7 */
};

static int
cp850_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 < 0x0100)
    c = cp850_page00[wc-0x00a0];
  else if (wc == 0x0131)
    c = 0xd5;
  else if (wc == 0x0192)
    c = 0x9f;
  else if (wc == 0x2017)
    c = 0xf2;
  else if (wc >= 0x2500 && wc < 0x25a8)
    c = cp850_page25[wc-0x2500];
  if (c != 0) {
    *r = c;
    return 1;
  }
  return RET_ILUNI;
}