diff options
author | Choe Hwanjin <choe.hwanjin@gmail.com> | 2004-11-08 20:39:11 +0900 |
---|---|---|
committer | Choe Hwanjin <choe.hwanjin@gmail.com> | 2004-11-08 20:39:11 +0900 |
commit | 0e0b2886d127cfe94b29c8ace8f7c70b6846223a (patch) | |
tree | 8a3ab443162f08d913b535fde27a74f619dc4fd7 /test | |
download | libhangul-0e0b2886d127cfe94b29c8ace8f7c70b6846223a.tar.gz |
Initial revision
git-svn-id: http://kldp.net/svn/hangul/trunk/hangul@3 8f00fcd2-89fc-0310-932e-b01be5b65e01
Diffstat (limited to 'test')
-rw-r--r-- | test/Makefile.am | 6 | ||||
-rw-r--r-- | test/test.c | 55 |
2 files changed, 61 insertions, 0 deletions
diff --git a/test/Makefile.am b/test/Makefile.am new file mode 100644 index 0000000..4a463be --- /dev/null +++ b/test/Makefile.am @@ -0,0 +1,6 @@ + +noinst_PROGRAMS = test + +test_CFLAGS = +test_SOURCES = test.c +test_LDADD = ../hangul/libhangul.a diff --git a/test/test.c b/test/test.c new file mode 100644 index 0000000..6492092 --- /dev/null +++ b/test/test.c @@ -0,0 +1,55 @@ +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <locale.h> +#include <wchar.h> + +#include "../hangul/hangul.h" + +int +main(int argc, char *argv[]) +{ + int n; + int ascii; + int keyboard = HANGUL_KEYBOARD_2; + char commit[32] = { '\0', }; + HangulInputContext *hic; + + if (argc > 1) { + keyboard = atoi(argv[1]); + } + + setlocale(LC_CTYPE, ""); + + hic = hangul_ic_new(keyboard); + if (hic == NULL) { + printf("hic is null\n"); + return -1; + } + + for (ascii = getchar(); ascii != EOF; ascii = getchar()) { + int ret = hangul_ic_filter(hic, ascii, 0); + n = wcstombs(commit, hangul_ic_get_commit_string(hic), sizeof(commit)); + commit[n] = '\0'; + if (strlen(commit) > 0) { + printf("%s", commit); + } + if (!ret) { + printf("%c", ascii); + } + } + hangul_ic_reset(hic); + n = wcstombs(commit, hangul_ic_get_commit_string(hic), sizeof(commit)); + commit[n] = '\0'; + if (strlen(commit) > 0) { + printf("%s", commit); + } + + hangul_ic_delete(hic); + + return 0; +} |