example2.c File Reference
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include <locale.h>`
`#include <librcc.h>`

## Functions

int | main (int argc, char *argv[])

## Function Documentation

## main()

int main | ( | int | argc,
|  | char * | argv[] )

{
// rcc_language_id language_id, current_language_id, english_language_id;
rcc_string rccstring;
const char *language;
char buf[255];
char *recoded;
rcc_class classes[] = {
{ "input", RCC_CLASS_STANDARD, NULL, NULL, "Input Encoding", 0 },
{ "output", RCC_CLASS_TRANSLATE_LOCALE, "LC_CTYPE", NULL, "Output Encoding", 0 },
{ NULL }
};
setlocale(LC_ALL, "");
rccInit();
rccInitDefaultContext(NULL, 0, 0, classes, 0);
rccInitDb4(NULL, "example", 0);
rccSetOption(NULL, RCC_OPTION_TRANSLATE, RCC_OPTION_TRANSLATE_SKIP_PARRENT);
rccSetOption(NULL, RCC_OPTION_AUTODETECT_LANGUAGE, 1);
// rccSetOption(NULL, RCC_OPTION_TIMEOUT, 5000000);
// rccSetOption(NULL, RCC_OPTION_CONFIGURED_LANGUAGES_ONLY, 0);
// current_language_id = rccGetCurrentLanguage(NULL);
// english_language_id = rccGetLanguageByName(NULL, "en");
if (argc>1) rccSetLanguageByName(NULL, argv[1]);
else rccSetOption(NULL, RCC_OPTION_AUTODETECT_LANGUAGE, 1);
// language_id = rccGetCurrentLanguage(NULL);
language = rccGetCurrentLanguageName(NULL);
if (language) printf("Current Language: %s\n\n", language);
else {
printf("Unable Detect Language, using english\n\n");
rccSetLanguageByName(NULL, "en");
}
while (fgets(buf,255,stdin)) {
if (strlen(buf)<2) break;
rccstring = rccFrom(NULL, 0, buf);
if (!rccstring) rccstring = strdup(buf);
if (rccstring) {
recoded = rccTo(NULL, 1, rccstring);
if (!recoded) recoded = strdup(rccstring);
if (recoded) {
printf("%s", recoded);
free(recoded);
}
free(rccstring);
}
}
rccFree();
return 0;
}
RCC_OPTION_TRANSLATE
@ RCC_OPTION_TRANSLATE
Definition librcc.h:466
RCC_OPTION_AUTODETECT_LANGUAGE
@ RCC_OPTION_AUTODETECT_LANGUAGE
Definition librcc.h:465
rccSetLanguageByName
int rccSetLanguageByName(rcc_context ctx, const char *name)
rccInitDefaultContext
int rccInitDefaultContext(const char *locale_variable, unsigned int max_languages, unsigned int max_classes, rcc_class_ptr defclasses, rcc_init_flags flags)
rccGetCurrentLanguageName
const char * rccGetCurrentLanguageName(rcc_context ctx)
rcc_string
char * rcc_string
Definition librcc.h:1032
rcc_class
const struct rcc_class_t rcc_class
Definition librcc.h:376
RCC_CLASS_STANDARD
@ RCC_CLASS_STANDARD
Definition librcc.h:314
RCC_CLASS_TRANSLATE_LOCALE
@ RCC_CLASS_TRANSLATE_LOCALE
Definition librcc.h:317
rccInit
int rccInit()
rccSetOption
int rccSetOption(rcc_context ctx, rcc_option option, rcc_option_value value)
rccTo
#define rccTo(ctx, class_id, buf)
Definition librcc.h:1454
rccInitDb4
int rccInitDb4(rcc_context ctx, const char *name, rcc_db4_flags flags)
rccFrom
#define rccFrom(ctx, class_id, buf)
Definition librcc.h:1453
rccFree
void rccFree()
RCC_OPTION_TRANSLATE_SKIP_PARRENT
#define RCC_OPTION_TRANSLATE_SKIP_PARRENT
Definition librcc.h:1554

References RCC_CLASS_STANDARD, RCC_CLASS_TRANSLATE_LOCALE, RCC_OPTION_AUTODETECT_LANGUAGE, RCC_OPTION_TRANSLATE, RCC_OPTION_TRANSLATE_SKIP_PARRENT, rccFree(), rccFrom, rccGetCurrentLanguageName(), rccInit(), rccInitDb4(), rccInitDefaultContext(), rccSetLanguageByName(), rccSetOption(), and rccTo.