nexmon – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | /* |
2 | * Copyright (C) 1999-2001 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 | * MacThai |
||
23 | */ |
||
24 | |||
25 | static const unsigned short mac_thai_2uni[128] = { |
||
26 | /* 0x80 */ |
||
27 | 0x00ab, 0x00bb, 0x2026, 0xf88c, 0xf88f, 0xf892, 0xf895, 0xf898, |
||
28 | 0xf88b, 0xf88e, 0xf891, 0xf894, 0xf897, 0x201c, 0x201d, 0xf899, |
||
29 | /* 0x90 */ |
||
30 | 0xfffd, 0x2022, 0xf884, 0xf889, 0xf885, 0xf886, 0xf887, 0xf888, |
||
31 | 0xf88a, 0xf88d, 0xf890, 0xf893, 0xf896, 0x2018, 0x2019, 0xfffd, |
||
32 | /* 0xa0 */ |
||
33 | 0x00a0, 0x0e01, 0x0e02, 0x0e03, 0x0e04, 0x0e05, 0x0e06, 0x0e07, |
||
34 | 0x0e08, 0x0e09, 0x0e0a, 0x0e0b, 0x0e0c, 0x0e0d, 0x0e0e, 0x0e0f, |
||
35 | /* 0xb0 */ |
||
36 | 0x0e10, 0x0e11, 0x0e12, 0x0e13, 0x0e14, 0x0e15, 0x0e16, 0x0e17, |
||
37 | 0x0e18, 0x0e19, 0x0e1a, 0x0e1b, 0x0e1c, 0x0e1d, 0x0e1e, 0x0e1f, |
||
38 | /* 0xc0 */ |
||
39 | 0x0e20, 0x0e21, 0x0e22, 0x0e23, 0x0e24, 0x0e25, 0x0e26, 0x0e27, |
||
40 | 0x0e28, 0x0e29, 0x0e2a, 0x0e2b, 0x0e2c, 0x0e2d, 0x0e2e, 0x0e2f, |
||
41 | /* 0xd0 */ |
||
42 | 0x0e30, 0x0e31, 0x0e32, 0x0e33, 0x0e34, 0x0e35, 0x0e36, 0x0e37, |
||
43 | 0x0e38, 0x0e39, 0x0e3a, 0xfeff, 0x200b, 0x2013, 0x2014, 0x0e3f, |
||
44 | /* 0xe0 */ |
||
45 | 0x0e40, 0x0e41, 0x0e42, 0x0e43, 0x0e44, 0x0e45, 0x0e46, 0x0e47, |
||
46 | 0x0e48, 0x0e49, 0x0e4a, 0x0e4b, 0x0e4c, 0x0e4d, 0x2122, 0x0e4f, |
||
47 | /* 0xf0 */ |
||
48 | 0x0e50, 0x0e51, 0x0e52, 0x0e53, 0x0e54, 0x0e55, 0x0e56, 0x0e57, |
||
49 | 0x0e58, 0x0e59, 0x00ae, 0x00a9, 0xfffd, 0xfffd, 0xfffd, 0xfffd, |
||
50 | }; |
||
51 | |||
52 | static int |
||
53 | mac_thai_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n) |
||
54 | { |
||
55 | unsigned char c = *s; |
||
56 | if (c < 0x80) { |
||
57 | *pwc = (ucs4_t) c; |
||
58 | return 1; |
||
59 | } |
||
60 | else { |
||
61 | unsigned short wc = mac_thai_2uni[c-0x80]; |
||
62 | if (wc != 0xfffd) { |
||
63 | *pwc = (ucs4_t) wc; |
||
64 | return 1; |
||
65 | } |
||
66 | } |
||
67 | return RET_ILSEQ; |
||
68 | } |
||
69 | |||
70 | static const unsigned char mac_thai_page00[32] = { |
||
71 | 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ |
||
72 | 0x00, 0xfb, 0x00, 0x80, 0x00, 0x00, 0xfa, 0x00, /* 0xa8-0xaf */ |
||
73 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */ |
||
74 | 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */ |
||
75 | }; |
||
76 | static const unsigned char mac_thai_page0e[96] = { |
||
77 | 0x00, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, /* 0x00-0x07 */ |
||
78 | 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, /* 0x08-0x0f */ |
||
79 | 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, /* 0x10-0x17 */ |
||
80 | 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, /* 0x18-0x1f */ |
||
81 | 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0x20-0x27 */ |
||
82 | 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* 0x28-0x2f */ |
||
83 | 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, /* 0x30-0x37 */ |
||
84 | 0xd8, 0xd9, 0xda, 0x00, 0x00, 0x00, 0x00, 0xdf, /* 0x38-0x3f */ |
||
85 | 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 0x40-0x47 */ |
||
86 | 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0x00, 0xef, /* 0x48-0x4f */ |
||
87 | 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 0x50-0x57 */ |
||
88 | 0xf8, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */ |
||
89 | }; |
||
90 | static const unsigned char mac_thai_page20[32] = { |
||
91 | 0x00, 0x00, 0x00, 0xdc, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */ |
||
92 | 0x00, 0x00, 0x00, 0xdd, 0xde, 0x00, 0x00, 0x00, /* 0x10-0x17 */ |
||
93 | 0x9d, 0x9e, 0x00, 0x00, 0x8d, 0x8e, 0x00, 0x00, /* 0x18-0x1f */ |
||
94 | 0x00, 0x00, 0x91, 0x00, 0x00, 0x00, 0x82, 0x00, /* 0x20-0x27 */ |
||
95 | }; |
||
96 | static const unsigned char mac_thai_pagef8[32] = { |
||
97 | 0x00, 0x00, 0x00, 0x00, 0x92, 0x94, 0x95, 0x96, /* 0x80-0x87 */ |
||
98 | 0x97, 0x93, 0x98, 0x88, 0x83, 0x99, 0x89, 0x84, /* 0x88-0x8f */ |
||
99 | 0x9a, 0x8a, 0x85, 0x9b, 0x8b, 0x86, 0x9c, 0x8c, /* 0x90-0x97 */ |
||
100 | 0x87, 0x8f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */ |
||
101 | }; |
||
102 | |||
103 | static int |
||
104 | mac_thai_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n) |
||
105 | { |
||
106 | unsigned char c = 0; |
||
107 | if (wc < 0x0080) { |
||
108 | *r = wc; |
||
109 | return 1; |
||
110 | } |
||
111 | else if (wc >= 0x00a0 && wc < 0x00c0) |
||
112 | c = mac_thai_page00[wc-0x00a0]; |
||
113 | else if (wc >= 0x0e00 && wc < 0x0e60) |
||
114 | c = mac_thai_page0e[wc-0x0e00]; |
||
115 | else if (wc >= 0x2008 && wc < 0x2028) |
||
116 | c = mac_thai_page20[wc-0x2008]; |
||
117 | else if (wc == 0x2122) |
||
118 | c = 0xee; |
||
119 | else if (wc >= 0xf880 && wc < 0xf8a0) |
||
120 | c = mac_thai_pagef8[wc-0xf880]; |
||
121 | else if (wc == 0xfeff) |
||
122 | c = 0xdb; |
||
123 | if (c != 0) { |
||
124 | *r = c; |
||
125 | return 1; |
||
126 | } |
||
127 | return RET_ILUNI; |
||
128 | } |