|
1 /* libhangul |
|
2 * Copyright (c) 2005,2006 Choe Hwanjin |
|
3 * All rights reserved. |
|
4 * This library is free software; you can redistribute it and/or |
|
5 * modify it under the terms of the GNU Lesser General Public |
|
6 * License as published by the Free Software Foundation; either |
|
7 * version 2.1 of the License, or (at your option) any later version. |
|
8 * |
|
9 * This library is distributed in the hope that it will be useful, |
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
12 * Lesser General Public License for more details. |
|
13 * |
|
14 * You should have received a copy of the GNU Lesser General Public |
|
15 * License along with this library; if not, write to the Free Software |
|
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|
17 */ |
|
18 |
|
19 #ifndef libhangul_hangul_h |
|
20 #define libhangul_hangul_h |
|
21 |
|
22 #include <stdbool.h> |
|
23 #include <inttypes.h> |
|
24 |
|
25 #ifdef __cplusplus |
|
26 extern "C" { |
|
27 #endif |
|
28 |
|
29 /* hangulctype.c */ |
|
30 enum { |
|
31 HANGUL_CHOSEONG_FILLER = 0x115f, /* hangul choseong filler */ |
|
32 HANGUL_JUNGSEONG_FILLER = 0x1160 /* hangul jungseong filler */ |
|
33 }; |
|
34 |
|
35 #ifdef __SYMBIAN32__ |
|
36 typedef uint16_t ucschar; |
|
37 #else |
|
38 typedef uint32_t ucschar; |
|
39 #endif |
|
40 |
|
41 bool hangul_is_choseong(ucschar c); |
|
42 bool hangul_is_jungseong(ucschar c); |
|
43 bool hangul_is_jongseong(ucschar c); |
|
44 bool hangul_is_choseong_conjoinable(ucschar c); |
|
45 bool hangul_is_jungseong_conjoinable(ucschar c); |
|
46 bool hangul_is_jongseong_conjoinable(ucschar c); |
|
47 bool hangul_is_syllable(ucschar c); |
|
48 bool hangul_is_jaso(ucschar c); |
|
49 bool hangul_is_jamo(ucschar c); |
|
50 |
|
51 ucschar hangul_jaso_to_jamo(ucschar ch); |
|
52 ucschar hangul_choseong_to_jamo(ucschar ch); |
|
53 ucschar hangul_jungseong_to_jamo(ucschar ch); |
|
54 ucschar hangul_jongseong_to_jamo(ucschar ch); |
|
55 |
|
56 ucschar hangul_choseong_to_jongseong(ucschar ch); |
|
57 ucschar hangul_jongseong_to_choseong(ucschar ch); |
|
58 void hangul_jongseong_dicompose(ucschar ch, ucschar* jong, ucschar* cho); |
|
59 |
|
60 const ucschar* hangul_syllable_iterator_prev(const ucschar* str, |
|
61 const ucschar* begin); |
|
62 const ucschar* hangul_syllable_iterator_next(const ucschar* str, |
|
63 const ucschar* end); |
|
64 |
|
65 int hangul_syllable_len(const ucschar* str, int max_len); |
|
66 |
|
67 ucschar hangul_jaso_to_syllable(ucschar choseong, |
|
68 ucschar jungseong, |
|
69 ucschar jongseong); |
|
70 void hangul_syllable_to_jaso(ucschar syllable, |
|
71 ucschar* choseong, |
|
72 ucschar* jungseong, |
|
73 ucschar* jongseong); |
|
74 int hangul_jamos_to_syllables(ucschar* dest, int destlen, |
|
75 const ucschar* src, int srclen); |
|
76 |
|
77 /* hangulinputcontext.c */ |
|
78 typedef struct _HangulKeyboard HangulKeyboard; |
|
79 typedef struct _HangulCombination HangulCombination; |
|
80 typedef struct _HangulBuffer HangulBuffer; |
|
81 typedef struct _HangulInputContext HangulInputContext; |
|
82 |
|
83 enum { |
|
84 HANGUL_OUTPUT_SYLLABLE, |
|
85 HANGUL_OUTPUT_JAMO |
|
86 }; |
|
87 |
|
88 enum { |
|
89 HANGUL_KEYBOARD_TYPE_JAMO, |
|
90 HANGUL_KEYBOARD_TYPE_JASO |
|
91 }; |
|
92 |
|
93 /* keyboard */ |
|
94 HangulKeyboard* hangul_keyboard_new(void); |
|
95 void hangul_keyboard_delete(HangulKeyboard *keyboard); |
|
96 void hangul_keyboard_set_value(HangulKeyboard *keyboard, |
|
97 int key, ucschar value); |
|
98 void hangul_keyboard_set_type(HangulKeyboard *keyboard, int type); |
|
99 |
|
100 /* combination */ |
|
101 HangulCombination* hangul_combination_new(void); |
|
102 void hangul_combination_delete(HangulCombination *combination); |
|
103 bool hangul_combination_set_data(HangulCombination* combination, |
|
104 ucschar* first, ucschar* second, ucschar* result, unsigned int n); |
|
105 |
|
106 /* input context */ |
|
107 HangulInputContext* hangul_ic_new(const char* keyboard); |
|
108 void hangul_ic_delete(HangulInputContext *hic); |
|
109 bool hangul_ic_process(HangulInputContext *hic, int ascii); |
|
110 void hangul_ic_reset(HangulInputContext *hic); |
|
111 bool hangul_ic_backspace(HangulInputContext *hic); |
|
112 |
|
113 bool hangul_ic_is_empty(HangulInputContext *hic); |
|
114 bool hangul_ic_has_choseong(HangulInputContext *hic); |
|
115 bool hangul_ic_has_jungseong(HangulInputContext *hic); |
|
116 bool hangul_ic_has_jongseong(HangulInputContext *hic); |
|
117 |
|
118 int hangul_ic_dvorak_to_qwerty(int qwerty); |
|
119 |
|
120 void hangul_ic_set_output_mode(HangulInputContext *hic, int mode); |
|
121 void hangul_ic_set_keyboard(HangulInputContext *hic, |
|
122 const HangulKeyboard *keyboard); |
|
123 void hangul_ic_select_keyboard(HangulInputContext *hic, |
|
124 const char* id); |
|
125 void hangul_ic_set_combination(HangulInputContext *hic, |
|
126 const HangulCombination *combination); |
|
127 void hangul_ic_connect_callback(HangulInputContext* hic, const char* event, |
|
128 void* callback, void* user_data); |
|
129 |
|
130 const ucschar* hangul_ic_get_preedit_string(HangulInputContext *hic); |
|
131 const ucschar* hangul_ic_get_commit_string(HangulInputContext *hic); |
|
132 const ucschar* hangul_ic_flush(HangulInputContext *hic); |
|
133 |
|
134 /* hanja.c */ |
|
135 typedef struct _Hanja Hanja; |
|
136 typedef struct _HanjaList HanjaList; |
|
137 typedef struct _HanjaTable HanjaTable; |
|
138 |
|
139 HanjaTable* hanja_table_load(const char *filename); |
|
140 HanjaList* hanja_table_match_exact(const HanjaTable* table, const char *key); |
|
141 HanjaList* hanja_table_match_prefix(const HanjaTable* table, const char *key); |
|
142 HanjaList* hanja_table_match_suffix(const HanjaTable* table, const char *key); |
|
143 void hanja_table_delete(HanjaTable *table); |
|
144 |
|
145 int hanja_table_txt_to_bin(const char* txtfilename, |
|
146 const char* binfilename); |
|
147 |
|
148 int hanja_list_get_size(const HanjaList *list); |
|
149 const char* hanja_list_get_key(const HanjaList *list); |
|
150 const Hanja* hanja_list_get_nth(const HanjaList *list, unsigned int n); |
|
151 const char* hanja_list_get_nth_key(const HanjaList *list, unsigned int n); |
|
152 const char* hanja_list_get_nth_value(const HanjaList *list, unsigned int n); |
|
153 const char* hanja_list_get_nth_comment(const HanjaList *list, unsigned int n); |
|
154 void hanja_list_delete(HanjaList *list); |
|
155 |
|
156 const char* hanja_get_key(const Hanja* hanja); |
|
157 const char* hanja_get_value(const Hanja* hanja); |
|
158 const char* hanja_get_comment(const Hanja* hanja); |
|
159 |
|
160 |
|
161 /* deprecated */ |
|
162 typedef bool (*HangulICFilter) (ucschar*, ucschar, ucschar, ucschar, void*); |
|
163 void hangul_ic_set_filter(HangulInputContext *hic, |
|
164 HangulICFilter func, void *user_data); |
|
165 |
|
166 #ifdef __cplusplus |
|
167 } |
|
168 #endif |
|
169 |
|
170 #endif /* libhangul_hangul_h */ |