diff options
author | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2005-07-14 19:39:08 +0000 |
---|---|---|
committer | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2005-07-14 19:39:08 +0000 |
commit | 7a6b6a56dabe1e62a0fbc6222c090aa077bcadc7 (patch) | |
tree | 1b509a460c238dc6a69c82930a9f726ee0a969e0 /examples/example.c | |
parent | 3e5322512be81527430059b901747df7692a6855 (diff) | |
download | librcc-7a6b6a56dabe1e62a0fbc6222c090aa077bcadc7.tar.gz librcc-7a6b6a56dabe1e62a0fbc6222c090aa077bcadc7.tar.bz2 librcc-7a6b6a56dabe1e62a0fbc6222c090aa077bcadc7.tar.xz librcc-7a6b6a56dabe1e62a0fbc6222c090aa077bcadc7.zip |
Example
Diffstat (limited to 'examples/example.c')
-rw-r--r-- | examples/example.c | 48 |
1 files changed, 27 insertions, 21 deletions
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(); } |