3 * Copyright (C) TSUBAKIMOTO Hiroya <zorac@4000do.co.jp> 2004
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 * http://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/
25 #endif /* HAVE_CONFIG_H */
29 #include "generic_cjk.h"
30 #include "mac_chinese_simp.h"
32 static size_t mac_chinese_simp_pull(void *,char **, size_t *, char **, size_t *);
33 static size_t mac_chinese_simp_push(void *,char **, size_t *, char **, size_t *);
35 struct charset_functions charset_mac_chinese_simp = {
38 mac_chinese_simp_pull,
39 mac_chinese_simp_push,
40 CHARSET_ICONV | CHARSET_MULTIBYTE | CHARSET_PRECOMPOSED | CHARSET_CLIENT,
45 static size_t mac_chinese_simp_char_push(u_int8_t* out, const ucs2_t* in, size_t* size)
51 out[0] = (u_int8_t)wc;
53 } else if ((wc & 0xf000) == 0xe000) {
56 } else if (*size >= 2 && (in[1] & ~15) == 0xf870) {
57 ucs2_t comp = cjk_compose(wc, in[1], mac_chinese_simp_compose,
58 sizeof(mac_chinese_simp_compose) / sizeof(u_int32_t));
68 return cjk_char_push(cjk_lookup(wc, mac_chinese_simp_uni2_index,
69 mac_chinese_simp_uni2_charset), out);
72 static size_t mac_chinese_simp_push(void *cd, char **inbuf, size_t *inbytesleft,
73 char **outbuf, size_t *outbytesleft)
75 return cjk_generic_push(mac_chinese_simp_char_push,
76 cd, inbuf, inbytesleft, outbuf, outbytesleft);
79 static size_t mac_chinese_simp_char_pull(ucs2_t* out, const u_int8_t* in, size_t* size)
87 } else if (c >= 0xa1 && c <= 0xfc) {
91 if (c2 >= 0xa1 && c2 <= 0xfe) {
105 return cjk_char_pull(cjk_lookup(c, mac_chinese_simp_2uni_index,
106 mac_chinese_simp_2uni_charset),
107 out, mac_chinese_simp_compose);
110 static size_t mac_chinese_simp_pull(void *cd, char **inbuf, size_t *inbytesleft,
111 char **outbuf, size_t *outbytesleft)
113 return cjk_generic_pull(mac_chinese_simp_char_pull,
114 cd, inbuf, inbytesleft, outbuf, outbytesleft);