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

1.1       misho       1: /*
1.1.1.2 ! misho       2:  * Copyright (C) 1999-2001, 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:  * ISO-8859-15
                     22:  */
                     23: 
                     24: static const unsigned short iso8859_15_2uni[32] = {
                     25:   /* 0xa0 */
                     26:   0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x20ac, 0x00a5, 0x0160, 0x00a7,
                     27:   0x0161, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
                     28:   /* 0xb0 */
                     29:   0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x017d, 0x00b5, 0x00b6, 0x00b7,
                     30:   0x017e, 0x00b9, 0x00ba, 0x00bb, 0x0152, 0x0153, 0x0178, 0x00bf,
                     31: };
                     32: 
                     33: static int
1.1.1.2 ! misho      34: iso8859_15_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 >= 0xa0 && c < 0xc0)
                     38:     *pwc = (ucs4_t) iso8859_15_2uni[c-0xa0];
                     39:   else
                     40:     *pwc = (ucs4_t) c;
                     41:   return 1;
                     42: }
                     43: 
                     44: static const unsigned char iso8859_15_page00[32] = {
                     45:   0xa0, 0xa1, 0xa2, 0xa3, 0x00, 0xa5, 0x00, 0xa7, /* 0xa0-0xa7 */
                     46:   0x00, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, /* 0xa8-0xaf */
                     47:   0xb0, 0xb1, 0xb2, 0xb3, 0x00, 0xb5, 0xb6, 0xb7, /* 0xb0-0xb7 */
                     48:   0x00, 0xb9, 0xba, 0xbb, 0x00, 0x00, 0x00, 0xbf, /* 0xb8-0xbf */
                     49: };
                     50: static const unsigned char iso8859_15_page01[48] = {
                     51:   0x00, 0x00, 0xbc, 0xbd, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */
                     52:   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */
                     53:   0xa6, 0xa8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */
                     54:   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */
                     55:   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */
                     56:   0xbe, 0x00, 0x00, 0x00, 0x00, 0xb4, 0xb8, 0x00, /* 0x78-0x7f */
                     57: };
                     58: 
                     59: static int
1.1.1.2 ! misho      60: iso8859_15_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
1.1       misho      61: {
                     62:   unsigned char c = 0;
                     63:   if (wc < 0x00a0) {
                     64:     *r = wc;
                     65:     return 1;
                     66:   }
                     67:   else if (wc >= 0x00a0 && wc < 0x00c0)
                     68:     c = iso8859_15_page00[wc-0x00a0];
                     69:   else if (wc >= 0x00c0 && wc < 0x0100)
                     70:     c = wc;
                     71:   else if (wc >= 0x0150 && wc < 0x0180)
                     72:     c = iso8859_15_page01[wc-0x0150];
                     73:   else if (wc == 0x20ac)
                     74:     c = 0xa4;
                     75:   if (c != 0) {
                     76:     *r = c;
                     77:     return 1;
                     78:   }
                     79:   return RET_ILUNI;
                     80: }

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