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

/*
 * ISO-8859-15
 */

static const unsigned short iso8859_15_2uni[32] = {
  /* 0xa0 */
  0x00a00x00a10x00a20x00a30x20ac0x00a50x01600x00a7,
  0x01610x00a90x00aa0x00ab0x00ac0x00ad0x00ae0x00af,
  /* 0xb0 */
  0x00b00x00b10x00b20x00b30x017d0x00b50x00b60x00b7,
  0x017e0x00b90x00ba0x00bb0x01520x01530x01780x00bf,
};

static int
iso8859_15_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
{
  unsigned char c = *s;
  if (c >= 0xa0 && c < 0xc0)
    *pwc = (ucs4_t) iso8859_15_2uni[c-0xa0];
  else
    *pwc = (ucs4_t) c;
  return 1;
}

static const unsigned char iso8859_15_page00[32] = {
  0xa00xa10xa20xa30x000xa50x000xa7/* 0xa0-0xa7 */
  0x000xa90xaa0xab0xac0xad0xae0xaf/* 0xa8-0xaf */
  0xb00xb10xb20xb30x000xb50xb60xb7/* 0xb0-0xb7 */
  0x000xb90xba0xbb0x000x000x000xbf/* 0xb8-0xbf */
};
static const unsigned char iso8859_15_page01[48] = {
  0x000x000xbc0xbd0x000x000x000x00/* 0x50-0x57 */
  0x000x000x000x000x000x000x000x00/* 0x58-0x5f */
  0xa60xa80x000x000x000x000x000x00/* 0x60-0x67 */
  0x000x000x000x000x000x000x000x00/* 0x68-0x6f */
  0x000x000x000x000x000x000x000x00/* 0x70-0x77 */
  0xbe0x000x000x000x000xb40xb80x00/* 0x78-0x7f */
};

static int
iso8859_15_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 < 0x00c0)
    c = iso8859_15_page00[wc-0x00a0];
  else if (wc >= 0x00c0 && wc < 0x0100)
    c = wc;
  else if (wc >= 0x0150 && wc < 0x0180)
    c = iso8859_15_page01[wc-0x0150];
  else if (wc == 0x20ac)
    c = 0xa4;
  if (c != 0) {
    *r = c;
    return 1;
  }
  return RET_ILUNI;
}