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

/*
 * MULELAO-1
 */

static const unsigned short mulelao_2uni[96] = {
  /* 0xa0 */
  0x00a00x0e810x0e820xfffd0x0e840xfffd0xfffd0x0e87,
  0x0e880xfffd0x0e8a0xfffd0xfffd0x0e8d0xfffd0xfffd,
  /* 0xb0 */
  0xfffd0xfffd0xfffd0xfffd0x0e940x0e950x0e960x0e97,
  0xfffd0x0e990x0e9a0x0e9b0x0e9c0x0e9d0x0e9e0x0e9f,
  /* 0xc0 */
  0xfffd0x0ea10x0ea20x0ea30xfffd0x0ea50xfffd0x0ea7,
  0xfffd0xfffd0x0eaa0x0eab0xfffd0x0ead0x0eae0x0eaf,
  /* 0xd0 */
  0x0eb00x0eb10x0eb20x0eb30x0eb40x0eb50x0eb60x0eb7,
  0x0eb80x0eb90xfffd0x0ebb0x0ebc0x0ebd0xfffd0xfffd,
  /* 0xe0 */
  0x0ec00x0ec10x0ec20x0ec30x0ec40xfffd0x0ec60xfffd,
  0x0ec80x0ec90x0eca0x0ecb0x0ecc0x0ecd0xfffd0xfffd,
  /* 0xf0 */
  0x0ed00x0ed10x0ed20x0ed30x0ed40x0ed50x0ed60x0ed7,
  0x0ed80x0ed90xfffd0xfffd0x0edc0x0edd0xfffd0xfffd,
};

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

static const unsigned char mulelao_page0e[96] = {
  0x000xa10xa20x000xa40x000x000xa7/* 0x80-0x87 */
  0xa80x000xaa0x000x000xad0x000x00/* 0x88-0x8f */
  0x000x000x000x000xb40xb50xb60xb7/* 0x90-0x97 */
  0x000xb90xba0xbb0xbc0xbd0xbe0xbf/* 0x98-0x9f */
  0x000xc10xc20xc30x000xc50x000xc7/* 0xa0-0xa7 */
  0x000x000xca0xcb0x000xcd0xce0xcf/* 0xa8-0xaf */
  0xd00xd10xd20xd30xd40xd50xd60xd7/* 0xb0-0xb7 */
  0xd80xd90x000xdb0xdc0xdd0x000x00/* 0xb8-0xbf */
  0xe00xe10xe20xe30xe40x000xe60x00/* 0xc0-0xc7 */
  0xe80xe90xea0xeb0xec0xed0x000x00/* 0xc8-0xcf */
  0xf00xf10xf20xf30xf40xf50xf60xf7/* 0xd0-0xd7 */
  0xf80xf90x000x000xfc0xfd0x000x00/* 0xd8-0xdf */
};

static int
mulelao_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)
    c = 0xa0;
  else if (wc >= 0x0e80 && wc < 0x0ee0)
    c = mulelao_page0e[wc-0x0e80];
  if (c != 0) {
    *r = c;
    return 1;
  }
  return RET_ILUNI;
}