Update after gnulib changed.
[libiconv.git] / lib / riscos1.h
blob0613d8993f9d629c6246a7a4fad7eb322d2aba9a
1 /*
2 * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc.
3 * This file is part of the GNU LIBICONV Library.
5 * The GNU LIBICONV Library is free software; you can redistribute it
6 * and/or modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either version 2.1
8 * of the License, or (at your option) any later version.
10 * The GNU LIBICONV Library is distributed in the hope that it will be
11 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with the GNU LIBICONV Library; see the file COPYING.LIB.
17 * If not, see <https://www.gnu.org/licenses/>.
21 * RISCOS-LATIN1
24 static const unsigned short riscos1_2uni[32] = {
25 /* 0x80 */
26 0x221a, 0x0174, 0x0175, 0x0083, 0x2573, 0x0176, 0x0177, 0x0087,
27 0x21e6, 0x21e8, 0x21e9, 0x21e7, 0x2026, 0x2122, 0x2030, 0x2022,
28 /* 0x90 */
29 0x2018, 0x2019, 0x2039, 0x203a, 0x201c, 0x201d, 0x201e, 0x2013,
30 0x2014, 0x2212, 0x0152, 0x0153, 0x2020, 0x2021, 0xfb01, 0xfb02,
33 static int
34 riscos1_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
36 unsigned char c = *s;
37 if (c >= 0x80 && c < 0xa0)
38 *pwc = (ucs4_t) riscos1_2uni[c-0x80];
39 else
40 *pwc = (ucs4_t) c;
41 return 1;
44 static const unsigned char riscos1_page01[40] = {
45 0x00, 0x00, 0x9a, 0x9b, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */
46 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */
47 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */
48 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */
49 0x00, 0x00, 0x00, 0x00, 0x81, 0x82, 0x85, 0x86, /* 0x70-0x77 */
51 static const unsigned char riscos1_page20[48] = {
52 0x00, 0x00, 0x00, 0x97, 0x98, 0x00, 0x00, 0x00, /* 0x10-0x17 */
53 0x90, 0x91, 0x00, 0x00, 0x94, 0x95, 0x96, 0x00, /* 0x18-0x1f */
54 0x9c, 0x9d, 0x8f, 0x00, 0x00, 0x00, 0x8c, 0x00, /* 0x20-0x27 */
55 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */
56 0x8e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */
57 0x00, 0x92, 0x93, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */
59 static const unsigned char riscos1_page21[16] = {
60 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x8b, /* 0xe0-0xe7 */
61 0x89, 0x8a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */
63 static const unsigned char riscos1_page22[16] = {
64 0x00, 0x00, 0x99, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */
65 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */
68 static int
69 riscos1_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
71 unsigned char c = 0;
72 if (wc < 0x0080 || wc == 0x0083 || wc == 0x0087 || (wc >= 0x00a0 && wc < 0x0100)) {
73 *r = wc;
74 return 1;
76 else if (wc >= 0x0150 && wc < 0x0178)
77 c = riscos1_page01[wc-0x0150];
78 else if (wc >= 0x2010 && wc < 0x2040)
79 c = riscos1_page20[wc-0x2010];
80 else if (wc == 0x2122)
81 c = 0x8d;
82 else if (wc >= 0x21e0 && wc < 0x21f0)
83 c = riscos1_page21[wc-0x21e0];
84 else if (wc >= 0x2210 && wc < 0x2220)
85 c = riscos1_page22[wc-0x2210];
86 else if (wc == 0x2573)
87 c = 0x84;
88 else if (wc >= 0xfb01 && wc < 0xfb03)
89 c = wc-0xfa63;
90 if (c != 0) {
91 *r = c;
92 return 1;
94 return RET_ILUNI;