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 */
30 #include "generic_cjk.h"
31 #include "mac_korean.h"
33 static size_t mac_korean_pull(void *,char **, size_t *, char **, size_t *);
34 static size_t mac_korean_push(void *,char **, size_t *, char **, size_t *);
36 struct charset_functions charset_mac_korean = {
41 CHARSET_ICONV | CHARSET_MULTIBYTE | CHARSET_PRECOMPOSED | CHARSET_CLIENT,
46 static size_t mac_korean_char_push(uint8_t* out, const ucs2_t* in, size_t* size)
50 if ((wc & ~7) == 0xf860) {
51 wc = cjk_compose_seq(in, size, mac_korean_compose,
52 sizeof(mac_korean_compose) / sizeof(uint32_t));
53 if (!wc) return (size_t)-1;
54 } else if ((wc & 0xf000) == 0xe000) {
57 } else if (*size >= 2) {
61 while ((comb & ~15) == 0xf870 ||
62 (comb >= 0x0300 && comb <= 0x036f) ||
63 (comb >= 0x20d0 && comb <= 0x20ea)) {
64 ucs2_t comp = cjk_compose(wc, comb, mac_korean_compose,
65 sizeof(mac_korean_compose) / sizeof(uint32_t));
68 if (++n == *size) break;
79 return cjk_char_push(cjk_lookup(wc, mac_korean_uni2_index,
80 mac_korean_uni2_charset), out);
83 static size_t mac_korean_push(void *cd, char **inbuf, size_t *inbytesleft,
84 char **outbuf, size_t *outbytesleft)
86 return cjk_generic_push(mac_korean_char_push,
87 cd, inbuf, inbytesleft, outbuf, outbytesleft);
90 static size_t mac_korean_char_pull(ucs2_t* out, const uint8_t* in, size_t* size)
98 } else if (c >= 0xa1 && c <= 0xfe) {
101 if ((c2 >= 0x41 && c2 <= 0x7d) || (c2 >= 0x81 && c2 <= 0xfe)) {
115 return cjk_char_pull(cjk_lookup(c, mac_korean_2uni_index,
116 mac_korean_2uni_charset),
117 out, mac_korean_compose);
120 static size_t mac_korean_pull(void *cd, char **inbuf, size_t *inbytesleft,
121 char **outbuf, size_t *outbytesleft)
123 return cjk_generic_pull(mac_korean_char_pull,
124 cd, inbuf, inbytesleft, outbuf, outbytesleft);