From 7a6b6a56dabe1e62a0fbc6222c090aa077bcadc7 Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Thu, 14 Jul 2005 19:39:08 +0000 Subject: Example --- examples/Makefile.am | 11 ++++-- examples/example.c | 48 ++++++++++++----------- examples/input-russian.txt | 4 ++ examples/input.txt | 4 -- examples/rcc-example.xml | 94 ++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 132 insertions(+), 29 deletions(-) create mode 100644 examples/input-russian.txt delete mode 100644 examples/input.txt (limited to 'examples') diff --git a/examples/Makefile.am b/examples/Makefile.am index 837a3cf..abf3ebb 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -1,7 +1,10 @@ bin_PROGRAMS= example example_SOURCES= example.c -example_LDADD= @RCD_LIBS@ -EXTRA_DIST= input.txt +example_LDADD= ../src/librcc.la -test: example - cat input.txt | ./example +EXTRA_DIST= input-russian.txt rcc.xml rcc-example.xml + +test-russian: example + cat input-russian.txt | ./example + +INCLUDES = -I../src -I../ui diff --git a/examples/example.c b/examples/example.c index 9666ae5..2053c61 100644 --- a/examples/example.c +++ b/examples/example.c @@ -1,31 +1,37 @@ #include -#include -#include +#include + +#include + +static rcc_class classes[] = { + { "input", RCC_CLASS_STANDARD, NULL, NULL, "Input Encoding" }, + { "output", RCC_CLASS_STANDARD, "LC_CTYPE", NULL, "Output Encoding" }, + { NULL } +}; main() { - enum russian_charsets res; + const char *language; char buf[255]; + char *recoded; int l; + + setlocale(LC_ALL, ""); + + rccInit(); + rccInitDefaultContext(NULL, 0, 0, classes, 0); + + language = rccGetCurrentLanguageName(NULL); + if (language) printf("Current Language: %s\n\n", language); + else printf("Unable Detect Language\n\n"); while (fgets(buf,255,stdin)) { if (strlen(buf)<2) break; - - res = get_russian_charset(buf,0); - switch(res) { - case RUSSIAN_CHARSET_WIN: - printf("CP1251: "); - break; - case RUSSIAN_CHARSET_ALT: - printf("CP866 : "); - break; - case RUSSIAN_CHARSET_KOI: - printf("KOI8-R: "); - break; - case RUSSIAN_CHARSET_UTF8: - printf("UTF8 : "); - break; - } - printf("%s",buf); - if (buf[strlen(buf)-1]!='\n') printf("\n"); + recoded = rccRecode(NULL, 0, 1, buf, 0, NULL); + if (recoded) { + printf(recoded); + free(recoded); + } else printf(buf); } + + rccFree(); } diff --git a/examples/input-russian.txt b/examples/input-russian.txt new file mode 100644 index 0000000..8ea6e44 --- /dev/null +++ b/examples/input-russian.txt @@ -0,0 +1,4 @@ + + +ਢ +привет diff --git a/examples/input.txt b/examples/input.txt deleted file mode 100644 index 8ea6e44..0000000 --- a/examples/input.txt +++ /dev/null @@ -1,4 +0,0 @@ - - -ਢ -привет diff --git a/examples/rcc-example.xml b/examples/rcc-example.xml index 3eeada9..5bf50b6 100644 --- a/examples/rcc-example.xml +++ b/examples/rcc-example.xml @@ -1,6 +1,12 @@ + + Автоопределение + + + Отключить + Russian Русский @@ -52,4 +58,92 @@ Поиск файлов + + + ID3 Encoding + Кодировка ID3 Тэгов + + + PlayList Encoding + Кодировка Списка Песен + + + PlayList File Encoding + Кодировка Файлов в Списке + + + FileSystem Encoding + Кодировка Файловой Системы + + + Output Encoding + Отображение + + + + + Авто-определение + + + KOI8-R (Кои) + + + CP1251 (Кодировка Windows) + + + ISO8859-5 (Кодировка ISO) + + + CP866 (Кодировка DOS) + + + Маковская Кодировка + + + UTF-8 (Юникод) + + + + + Отключить + + + Библиотека LibRCD + + + Библиотека Enca + + + + + RusXMMS + РусXMMS + + + Language + Язык + + + Current Language + Текущий Язык + + + + + AutoDetection + Авто-определение + + + Engine + Движок + + + + + Encodings + Кодировки + + + + \ No newline at end of file -- cgit v1.2.3