diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/Makefile.am | 11 | ||||
-rw-r--r-- | examples/example.c | 48 | ||||
-rw-r--r-- | examples/input-russian.txt (renamed from examples/input.txt) | 0 | ||||
-rw-r--r-- | examples/rcc-example.xml | 94 |
4 files changed, 128 insertions, 25 deletions
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 <stdio.h> -#include <string.h> -#include <librcd.h> +#include <locale.h> + +#include <librcc.h> + +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.txt b/examples/input-russian.txt index 8ea6e44..8ea6e44 100644 --- a/examples/input.txt +++ b/examples/input-russian.txt 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 @@ <?xml version='1.0' encoding="UTF-8"?> <LibRCC> <Languages> + <Language name="default"> + <FullName locale="ru">Автоопределение</FullName> + </Language> + <Language name="off"> + <FullName locale="ru">Отключить</FullName> + </Language> <Language name="ru"> <FullName>Russian</FullName> <FullName locale="ru">Русский</FullName> @@ -52,4 +58,92 @@ <FullName locale="ru">Поиск файлов</FullName> </Option> </Options> + <Classes> + <Class name="id3"> + <FullName>ID3 Encoding</FullName> + <FullName locale="ru">Кодировка ID3 Тэгов</FullName> + </Class> + <Class name="pl"> + <FullName>PlayList Encoding</FullName> + <FullName locale="ru">Кодировка Списка Песен</FullName> + </Class> + <Class name="plfs"> + <FullName>PlayList File Encoding</FullName> + <FullName locale="ru">Кодировка Файлов в Списке</FullName> + </Class> + <Class name="fs"> + <FullName>FileSystem Encoding</FullName> + <FullName locale="ru">Кодировка Файловой Системы</FullName> + </Class> + <Class name="out"> + <FullName>Output Encoding</FullName> + <FullName locale="ru">Отображение</FullName> + </Class> + </Classes> + <Charsets> + <Charset name="Default"> + <FullName locale="ru">Авто-определение</FullName> + </Charset> + <Charset name="KOI8-R"> + <FullName locale="ru">KOI8-R (Кои)</FullName> + </Charset> + <Charset name="CP1251"> + <FullName locale="ru">CP1251 (Кодировка Windows)</FullName> + </Charset> + <Charset name="ISO8859-5"> + <FullName locale="ru">ISO8859-5 (Кодировка ISO)</FullName> + </Charset> + <Charset name="IBM866"> + <FullName locale="ru">CP866 (Кодировка DOS)</FullName> + </Charset> + <Charset name="MACCYRILLIC"> + <FullName locale="ru">Маковская Кодировка</FullName> + </Charset> + <Charset name="UTF-8"> + <FullName locale="ru">UTF-8 (Юникод)</FullName> + </Charset> + </Charsets> + <Engines> + <Engine name="off"> + <FullName locale="ru">Отключить</FullName> + </Engine> + <Engine name="Russian"> + <FullName locale="ru">Библиотека LibRCD</FullName> + </Engine> + <Engine name="Enca Library"> + <FullName locale="ru">Библиотека Enca</FullName> + </Engine> + </Engines> + <Pages> + <Page name="RusXMMS"> + <FullName>RusXMMS</FullName> + <FullName locale="ru">РусXMMS</FullName> + <Frames> + <Frame name="Language"> + <FullName>Language</FullName> + <FullName locale="ru">Язык</FullName> + <Boxes> + <Box name="Language"> + <FullName>Current Language</FullName> + <FullName locale="ru">Текущий Язык</FullName> + </Box> + </Boxes> + </Frame> + <Frame name="Engine"> + <FullName>AutoDetection</FullName> + <FullName locale="ru">Авто-определение</FullName> + <Boxes> + <Box name="Engine"> + <FullName>Engine</FullName> + <FullName locale="ru">Движок</FullName> + </Box> + </Boxes> + </Frame> + <Frame name="Charset"> + <FullName>Encodings</FullName> + <FullName locale="ru">Кодировки</FullName> + </Frame> + </Frames> + </Page> + </Pages> </LibRCC>
\ No newline at end of file |