Annotation of embedaddon/libiconv/lib/riscos1.h, revision 1.1.1.2

1.1       misho       1: /*
1.1.1.2 ! misho       2:  * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc.
1.1       misho       3:  * This file is part of the GNU LIBICONV Library.
                      4:  *
                      5:  * The GNU LIBICONV Library is free software; you can redistribute it
                      6:  * and/or modify it under the terms of the GNU Library General Public
                      7:  * License as published by the Free Software Foundation; either version 2
                      8:  * of the License, or (at your option) any later version.
                      9:  *
                     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:  * Library General Public License for more details.
                     14:  *
                     15:  * You should have received a copy of the GNU Library General Public
                     16:  * License along with the GNU LIBICONV Library; see the file COPYING.LIB.
1.1.1.2 ! misho      17:  * If not, see <https://www.gnu.org/licenses/>.
1.1       misho      18:  */
                     19: 
                     20: /*
                     21:  * RISCOS-LATIN1
                     22:  */
                     23: 
                     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,
                     31: };
                     32: 
                     33: static int
1.1.1.2 ! misho      34: riscos1_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
1.1       misho      35: {
                     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;
                     42: }
                     43: 
                     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 */
                     50: };
                     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 */
                     58: };
                     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 */
                     62: };
                     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 */
                     66: };
                     67: 
                     68: static int
1.1.1.2 ! misho      69: riscos1_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
1.1       misho      70: {
                     71:   unsigned char c = 0;
                     72:   if (wc < 0x0080 || wc == 0x0083 || wc == 0x0087 || (wc >= 0x00a0 && wc < 0x0100)) {
                     73:     *r = wc;
                     74:     return 1;
                     75:   }
                     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;
                     93:   }
                     94:   return RET_ILUNI;
                     95: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>