* hangul_buffer_has_choseong(), hangul_buffer_has_jungseong(),
hangul_buffer_has_jongseong() 추가
git-svn-id: http://kldp.net/svn/hangul/libhangul/trunk@114
8f00fcd2-89fc-0310-932e-
b01be5b65e01
bool hangul_ic_process(HangulInputContext *hic, int ascii);
void hangul_ic_reset(HangulInputContext *hic);
bool hangul_ic_backspace(HangulInputContext *hic);
+
bool hangul_ic_is_empty(HangulInputContext *hic);
+bool hangul_ic_has_choseong(HangulInputContext *hic);
+bool hangul_ic_has_jungseong(HangulInputContext *hic);
+bool hangul_ic_has_jongseong(HangulInputContext *hic);
+
int hangul_ic_dvorak_to_qwerty(int qwerty);
void hangul_ic_set_output_mode(HangulInputContext *hic, int mode);
#include <config.h>
#endif
+#include <stdlib.h>
+
#include "hangul.h"
/**
return c;
}
+void
+hangul_syllable_to_jaso(ucschar syllable,
+ ucschar* choseong,
+ ucschar* jungseong,
+ ucschar* jongseong)
+{
+ static const ucschar hangul_base = 0xac00;
+ static const ucschar choseong_base = 0x1100;
+ static const ucschar jungseong_base = 0x1161;
+ static const ucschar jongseong_base = 0x11a7;
+ static const int njungseong = 21;
+ static const int njongseong = 28;
+
+ if (!hangul_is_syllable(syllable)) {
+ if (jongseong != NULL)
+ *jongseong = 0;
+ if (jungseong != NULL)
+ *jungseong = 0;
+ if (choseong != NULL)
+ *choseong = 0;
+ return;
+ }
+
+ syllable -= hangul_base;
+
+ if (jongseong != NULL) {
+ *jongseong = jongseong_base + syllable % njongseong;
+ }
+ syllable /= njongseong;
+
+ if (jungseong != NULL) {
+ *jungseong = jungseong_base + syllable % njungseong;
+ }
+ syllable /= njungseong;
+
+ if (choseong != NULL) {
+ *choseong = choseong_base + syllable;
+ }
+}
buffer->jongseong == 0;
}
+static bool
+hangul_buffer_has_choseong(HangulBuffer *buffer)
+{
+ return buffer->choseong != 0;
+}
+
+static bool
+hangul_buffer_has_jungseong(HangulBuffer *buffer)
+{
+ return buffer->jungseong != 0;
+}
+
+static bool
+hangul_buffer_has_jongseong(HangulBuffer *buffer)
+{
+ return buffer->jongseong != 0;
+}
+
static void
hangul_buffer_push(HangulBuffer *buffer, ucschar ch)
{
return hangul_buffer_is_empty(&hic->buffer);
}
+bool
+hangul_ic_has_choseong(HangulInputContext *hic)
+{
+ return hangul_buffer_has_choseong(&hic->buffer);
+}
+
+bool
+hangul_ic_has_jungseong(HangulInputContext *hic)
+{
+ return hangul_buffer_has_jungseong(&hic->buffer);
+}
+
+bool
+hangul_ic_has_jongseong(HangulInputContext *hic)
+{
+ return hangul_buffer_has_jongseong(&hic->buffer);
+}
+
void
hangul_ic_set_output_mode(HangulInputContext *hic, int mode)
{