summaryrefslogtreecommitdiff
path: root/jni/iconv/lib/tds565.h
blob: 479513fedf98f3a0e77a28366f9d9111cabeab2f (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
/*
 * Copyright (C) 1999-2002 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.
 */

/*
 * TDS565
 */

static const unsigned short tds565_2uni[64] = {
  /* 0x40 */
  0x00400x00410x00420x00c70x00440x00450x00c40x0046,
  0x00470x00480x00490x004a0x017d0x004b0x004c0x004d,
  /* 0x50 */
  0x004e0x01470x004f0x00d60x00500x00520x00530x015e,
  0x00540x00550x00dc0x00570x00590x00dd0x005a0x005f,
  /* 0x60 */
  0x21160x00610x00620x00e70x00640x00650x00e40x0066,
  0x00670x00680x00690x006a0x017e0x006b0x006c0x006d,
  /* 0x70 */
  0x006e0x01480x006f0x00f60x00700x00720x00730x015f,
  0x00740x00750x00fc0x00770x00790x00fd0x007a0x007f,
};

static int
tds565_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
{
  unsigned char c = *s;
  if (c < 0x40) {
    *pwc = (ucs4_t) c;
    return 1;
  }
  else if (c < 0x80) {
    *pwc = (ucs4_t) tds565_2uni[c-0x40];
    return 1;
  }
  return RET_ILSEQ;
}

static const unsigned char tds565_page00[64] = {
  0x400x410x420x000x440x450x470x48/* 0x40-0x47 */
  0x490x4a0x4b0x4d0x4e0x4f0x500x52/* 0x48-0x4f */
  0x540x000x550x560x580x590x000x5b/* 0x50-0x57 */
  0x000x5c0x5e0x000x000x000x000x5f/* 0x58-0x5f */
  0x000x610x620x000x640x650x670x68/* 0x60-0x67 */
  0x690x6a0x6b0x6d0x6e0x6f0x700x72/* 0x68-0x6f */
  0x740x000x750x760x780x790x000x7b/* 0x70-0x77 */
  0x000x7c0x7e0x000x000x000x000x7f/* 0x78-0x7f */
};
static const unsigned char tds565_page00_1[64] = {
  0x000x000x000x000x460x000x000x43/* 0xc0-0xc7 */
  0x000x000x000x000x000x000x000x00/* 0xc8-0xcf */
  0x000x000x000x000x000x000x530x00/* 0xd0-0xd7 */
  0x000x000x000x000x5a0x5d0x000x00/* 0xd8-0xdf */
  0x000x000x000x000x660x000x000x63/* 0xe0-0xe7 */
  0x000x000x000x000x000x000x000x00/* 0xe8-0xef */
  0x000x000x000x000x000x000x730x00/* 0xf0-0xf7 */
  0x000x000x000x000x7a0x7d0x000x00/* 0xf8-0xff */
};
static const unsigned char tds565_page01[64] = {
  0x000x000x000x000x000x000x000x51/* 0x40-0x47 */
  0x710x000x000x000x000x000x000x00/* 0x48-0x4f */
  0x000x000x000x000x000x000x000x00/* 0x50-0x57 */
  0x000x000x000x000x000x000x570x77/* 0x58-0x5f */
  0x000x000x000x000x000x000x000x00/* 0x60-0x67 */
  0x000x000x000x000x000x000x000x00/* 0x68-0x6f */
  0x000x000x000x000x000x000x000x00/* 0x70-0x77 */
  0x000x000x000x000x000x4c0x6c0x00/* 0x78-0x7f */
};

static int
tds565_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
{
  unsigned char c = 0;
  if (wc < 0x0040) {
    *r = wc;
    return 1;
  }
  else if (wc >= 0x0040 && wc < 0x0080)
    c = tds565_page00[wc-0x0040];
  else if (wc >= 0x00c0 && wc < 0x0100)
    c = tds565_page00_1[wc-0x00c0];
  else if (wc >= 0x0140 && wc < 0x0180)
    c = tds565_page01[wc-0x0140];
  else if (wc == 0x2116)
    c = 0x60;
  if (c != 0) {
    *r = c;
    return 1;
  }
  return RET_ILUNI;
}