From 3736c5f3635863e54ab2cc47860628d26855c749 Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Thu, 11 Aug 2005 01:06:56 +0000 Subject: Transliteration and Documentation Update - Fix: Autodetection of dissabled charsets. - Fix: Cleanely terminate external process if parrent thread terminated. - Transliteration for Russian, Ukrainian and using IConv. - Documentation Update. --- src/recode.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) (limited to 'src/recode.c') diff --git a/src/recode.c b/src/recode.c index a528481..9e19078 100644 --- a/src/recode.c +++ b/src/recode.c @@ -322,7 +322,9 @@ static char *rccRecodeTranslate(rcc_language_config *config, rcc_class_id class_ rcc_translate trans, entrans; + unsigned int i; char *translated; + unsigned char change_case; ctx = (*config)->ctx; @@ -336,7 +338,7 @@ static char *rccRecodeTranslate(rcc_language_config *config, rcc_class_id class_ english_language_id = rccGetLanguageByName(ctx, rcc_english_language_sn); - if (translate == RCC_OPTION_TRANSLATE_TO_ENGLISH) { + if ((translate == RCC_OPTION_TRANSLATE_TO_ENGLISH)||(translate == RCC_OPTION_TRANSLATE_TRANSLITERATE)) { current_language_id = english_language_id ; } else { if (ctype == RCC_CLASS_TRANSLATE_LOCALE) { @@ -356,6 +358,49 @@ static char *rccRecodeTranslate(rcc_language_config *config, rcc_class_id class_ if (rccConfigConfigure(curconfig)) return NULL; + if (translate == RCC_OPTION_TRANSLATE_TRANSLITERATE) { + if (!strcasecmp((*config)->language->sn, rcc_russian_language_sn)) { + translated = rccSizedRecodeCharsets(ctx, "UTF-8", "KOI8-R", utfstring, 0, NULL); + if (!translated) return NULL; + for (i=0;translated[i];i++) { + if (translated[i]&0x80) change_case = 1; + else change_case = 0; + + translated[i]=translated[i]&0x7F; + if (change_case) { + if ((translated[i]<'Z')&&(translated[i]>'A')) + translated[i]=translated[i]-'A'+'a'; + else if ((translated[i]<'z')&&(translated[i]>'a')) + translated[i]=translated[i]-'a'+'A'; + } + } + *config = curconfig; + return translated; + } + if (!strcasecmp((*config)->language->sn, rcc_ukrainian_language_sn)) { + translated = rccSizedRecodeCharsets(ctx, "UTF-8", "KOI8-U", utfstring, 0, NULL); + if (!translated) return NULL; + for (i=0;translated[i];i++) { + if (translated[i]&0x80) change_case = 1; + else change_case = 0; + + translated[i]=translated[i]&0x7F; + if (change_case) { + if ((translated[i]<'Z')&&(translated[i]>'A')) + translated[i]=translated[i]-'A'+'a'; + else if ((translated[i]<'z')&&(translated[i]>'a')) + translated[i]=translated[i]-'a'+'A'; + } + } + *config = curconfig; + return translated; + } + + translated = rccSizedRecodeCharsets(ctx, "UTF-8", "US-ASCII//TRANSLIT", utfstring, 0, NULL); + if (translated) *config = curconfig; + return translated; + } + if (translate == RCC_OPTION_TRANSLATE_SKIP_RELATED) { if (rccAreRelatedLanguages(curconfig, *config)) return NULL; } -- cgit v1.2.3