nexmon – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | /* |
2 | * Copyright (C) 1999-2002 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, write to the Free Software Foundation, Inc., 51 Franklin Street, |
||
18 | * Fifth Floor, Boston, MA 02110-1301, USA. |
||
19 | */ |
||
20 | |||
21 | /* |
||
22 | * CP1161 |
||
23 | */ |
||
24 | |||
25 | static const unsigned short cp1161_2uni[96] = { |
||
26 | /* 0xa0 */ |
||
27 | 0x0e48, 0x0e01, 0x0e02, 0x0e03, 0x0e04, 0x0e05, 0x0e06, 0x0e07, |
||
28 | 0x0e08, 0x0e09, 0x0e0a, 0x0e0b, 0x0e0c, 0x0e0d, 0x0e0e, 0x0e0f, |
||
29 | /* 0xb0 */ |
||
30 | 0x0e10, 0x0e11, 0x0e12, 0x0e13, 0x0e14, 0x0e15, 0x0e16, 0x0e17, |
||
31 | 0x0e18, 0x0e19, 0x0e1a, 0x0e1b, 0x0e1c, 0x0e1d, 0x0e1e, 0x0e1f, |
||
32 | /* 0xc0 */ |
||
33 | 0x0e20, 0x0e21, 0x0e22, 0x0e23, 0x0e24, 0x0e25, 0x0e26, 0x0e27, |
||
34 | 0x0e28, 0x0e29, 0x0e2a, 0x0e2b, 0x0e2c, 0x0e2d, 0x0e2e, 0x0e2f, |
||
35 | /* 0xd0 */ |
||
36 | 0x0e30, 0x0e31, 0x0e32, 0x0e33, 0x0e34, 0x0e35, 0x0e36, 0x0e37, |
||
37 | 0x0e38, 0x0e39, 0x0e3a, 0x0e49, 0x0e4a, 0x0e4b, 0x20ac, 0x0e3f, |
||
38 | /* 0xe0 */ |
||
39 | 0x0e40, 0x0e41, 0x0e42, 0x0e43, 0x0e44, 0x0e45, 0x0e46, 0x0e47, |
||
40 | 0x0e48, 0x0e49, 0x0e4a, 0x0e4b, 0x0e4c, 0x0e4d, 0x0e4e, 0x0e4f, |
||
41 | /* 0xf0 */ |
||
42 | 0x0e50, 0x0e51, 0x0e52, 0x0e53, 0x0e54, 0x0e55, 0x0e56, 0x0e57, |
||
43 | 0x0e58, 0x0e59, 0x0e5a, 0x0e5b, 0x00a2, 0x00ac, 0x00a6, 0x00a0, |
||
44 | }; |
||
45 | |||
46 | static int |
||
47 | cp1161_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n) |
||
48 | { |
||
49 | unsigned char c = *s; |
||
50 | if (c < 0x80) { |
||
51 | *pwc = (ucs4_t) c; |
||
52 | return 1; |
||
53 | } |
||
54 | else if (c < 0xa0) { |
||
55 | } |
||
56 | else { |
||
57 | *pwc = (ucs4_t) cp1161_2uni[c-0xa0]; |
||
58 | return 1; |
||
59 | } |
||
60 | return RET_ILSEQ; |
||
61 | } |
||
62 | |||
63 | static const unsigned char cp1161_page00[16] = { |
||
64 | 0xff, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfe, 0x00, /* 0xa0-0xa7 */ |
||
65 | 0x00, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x00, 0x00, /* 0xa8-0xaf */ |
||
66 | }; |
||
67 | |||
68 | static int |
||
69 | cp1161_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n) |
||
70 | { |
||
71 | unsigned char c = 0; |
||
72 | if (wc < 0x0080) { |
||
73 | *r = wc; |
||
74 | return 1; |
||
75 | } |
||
76 | else if (wc >= 0x00a0 && wc < 0x00b0) |
||
77 | c = cp1161_page00[wc-0x00a0]; |
||
78 | else if (wc >= 0x0e48 && wc < 0x0e4c) |
||
79 | c = wc-0x0d60; |
||
80 | else if (wc >= 0x0e00 && wc < 0x0e60) |
||
81 | c = cp874_page0e[wc-0x0e00]; |
||
82 | else if (wc == 0x20ac) |
||
83 | c = 0xde; |
||
84 | if (c != 0) { |
||
85 | *r = c; |
||
86 | return 1; |
||
87 | } |
||
88 | return RET_ILUNI; |
||
89 | } |