Annotation of embedaddon/libiconv/lib/cp50221_0208_ext.h, revision 1.1
1.1 ! misho 1: /*
! 2: * Copyright (C) 1999-2012, 2016 Free Software Foundation, Inc.
! 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.
! 17: * If not, see <https://www.gnu.org/licenses/>.
! 18: */
! 19:
! 20: /*
! 21: * CP50221 JISX0208 extensions
! 22: */
! 23:
! 24: static const unsigned short cp50221_0208_ext_2uni[96] = {
! 25: /* 0x00 */
! 26: 0xfffd, 0x2460, 0x2461, 0x2462, 0x2463, 0x2464, 0x2465, 0x2466,
! 27: 0x2467, 0x2468, 0x2469, 0x246a, 0x246b, 0x246c, 0x246d, 0x246e,
! 28: /* 0x10 */
! 29: 0x246f, 0x2470, 0x2471, 0x2472, 0x2473, 0x2160, 0x2161, 0x2162,
! 30: 0x2163, 0x2164, 0x2165, 0x2166, 0x2167, 0x2168, 0x2169, 0xfffd,
! 31: /* 0x20 */
! 32: 0x3349, 0x3314, 0x3322, 0x334d, 0x3318, 0x3327, 0x3303, 0x3336,
! 33: 0x3351, 0x3357, 0x330d, 0x3326, 0x3323, 0x332b, 0x334a, 0x333b,
! 34: /* 0x30 */
! 35: 0x339c, 0x339d, 0x339e, 0x338e, 0x338f, 0x33c4, 0x33a1, 0xfffd,
! 36: 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0x337b,
! 37: /* 0x40 */
! 38: 0x301e, 0x301f, 0x2116, 0x33cd, 0x2121, 0x32a4, 0x32a5, 0x32a6,
! 39: 0x32a7, 0x32a8, 0x3231, 0x3232, 0x3239, 0x337e, 0x337d, 0x337c,
! 40: /* 0x50 */
! 41: 0xfffd, 0xfffd, 0xfffd, 0x222e, 0x2211, 0xfffd, 0xfffd, 0xfffd,
! 42: 0x221f, 0x22bf, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
! 43: };
! 44:
! 45: static int
! 46: cp50221_0208_ext_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
! 47: {
! 48: unsigned char c = *s;
! 49: if (c < 0x60) {
! 50: unsigned short wc = cp50221_0208_ext_2uni[c];
! 51: if (wc != 0xfffd) {
! 52: *pwc = (ucs4_t) wc;
! 53: return 1;
! 54: }
! 55: }
! 56: return RET_ILSEQ;
! 57: }
! 58:
! 59: static const unsigned char cp50221_0208_ext_page21[96] = {
! 60: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, /* 0x10-0x17 */
! 61: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */
! 62: 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */
! 63: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */
! 64: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */
! 65: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */
! 66: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x47 */
! 67: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4f */
! 68: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */
! 69: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */
! 70: 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, /* 0x60-0x67 */
! 71: 0x1d, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */
! 72: };
! 73: static const unsigned char cp50221_0208_ext_page22[32] = {
! 74: 0x00, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */
! 75: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, /* 0x18-0x1f */
! 76: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */
! 77: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x53, 0x00, /* 0x28-0x2f */
! 78: };
! 79: static const unsigned char cp50221_0208_ext_page24[24] = {
! 80: 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, /* 0x60-0x67 */
! 81: 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, /* 0x68-0x6f */
! 82: 0x11, 0x12, 0x13, 0x14, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */
! 83: };
! 84: static const unsigned char cp50221_0208_ext_page30[8] = {
! 85: 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x41, /* 0x18-0x1f */
! 86: };
! 87: static const unsigned char cp50221_0208_ext_page32[16] = {
! 88: 0x00, 0x4a, 0x4b, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */
! 89: 0x00, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */
! 90: };
! 91: static const unsigned char cp50221_0208_ext_page32_1[16] = {
! 92: 0x00, 0x00, 0x00, 0x00, 0x45, 0x46, 0x47, 0x48, /* 0xa0-0xa7 */
! 93: 0x49, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa8-0xaf */
! 94: };
! 95: static const unsigned char cp50221_0208_ext_page33[208] = {
! 96: 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */
! 97: 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, /* 0x08-0x0f */
! 98: 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, /* 0x10-0x17 */
! 99: 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */
! 100: 0x00, 0x00, 0x22, 0x2c, 0x00, 0x00, 0x2b, 0x25, /* 0x20-0x27 */
! 101: 0x00, 0x00, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */
! 102: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x27, 0x00, /* 0x30-0x37 */
! 103: 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */
! 104: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x47 */
! 105: 0x00, 0x20, 0x2e, 0x00, 0x00, 0x23, 0x00, 0x00, /* 0x48-0x4f */
! 106: 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x29, /* 0x50-0x57 */
! 107: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */
! 108: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */
! 109: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */
! 110: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */
! 111: 0x00, 0x00, 0x00, 0x3f, 0x4f, 0x4e, 0x4d, 0x00, /* 0x78-0x7f */
! 112: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */
! 113: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x34, /* 0x88-0x8f */
! 114: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */
! 115: 0x00, 0x00, 0x00, 0x00, 0x30, 0x31, 0x32, 0x00, /* 0x98-0x9f */
! 116: 0x00, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */
! 117: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa8-0xaf */
! 118: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */
! 119: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */
! 120: 0x00, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */
! 121: 0x00, 0x00, 0x00, 0x00, 0x00, 0x43, 0x00, 0x00, /* 0xc8-0xcf */
! 122: };
! 123:
! 124: static int
! 125: cp50221_0208_ext_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
! 126: {
! 127: unsigned char c = 0;
! 128: if (wc >= 0x2110 && wc < 0x2170)
! 129: c = cp50221_0208_ext_page21[wc-0x2110];
! 130: else if (wc >= 0x2210 && wc < 0x2230)
! 131: c = cp50221_0208_ext_page22[wc-0x2210];
! 132: else if (wc == 0x22bf)
! 133: c = 0x59;
! 134: else if (wc >= 0x2460 && wc < 0x2478)
! 135: c = cp50221_0208_ext_page24[wc-0x2460];
! 136: else if (wc >= 0x3018 && wc < 0x3020)
! 137: c = cp50221_0208_ext_page30[wc-0x3018];
! 138: else if (wc >= 0x3230 && wc < 0x3240)
! 139: c = cp50221_0208_ext_page32[wc-0x3230];
! 140: else if (wc >= 0x32a0 && wc < 0x32b0)
! 141: c = cp50221_0208_ext_page32_1[wc-0x32a0];
! 142: else if (wc >= 0x3300 && wc < 0x33d0)
! 143: c = cp50221_0208_ext_page33[wc-0x3300];
! 144: if (c != 0) {
! 145: *r = c;
! 146: return 1;
! 147: }
! 148: return RET_ILUNI;
! 149: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>