summaryrefslogtreecommitdiffstats
path: root/src/recode.c
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@dside.dyndns.org>2005-08-11 01:06:56 +0000
committerSuren A. Chilingaryan <csa@dside.dyndns.org>2005-08-11 01:06:56 +0000
commit3736c5f3635863e54ab2cc47860628d26855c749 (patch)
tree3c1dadec1b75557463fcc740429cceb6e948f998 /src/recode.c
parent63bf2a90a6d6fb0859e4c9dd9fcac85de9adc0f1 (diff)
downloadlibrcc-3736c5f3635863e54ab2cc47860628d26855c749.tar.gz
librcc-3736c5f3635863e54ab2cc47860628d26855c749.tar.bz2
librcc-3736c5f3635863e54ab2cc47860628d26855c749.tar.xz
librcc-3736c5f3635863e54ab2cc47860628d26855c749.zip
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.
Diffstat (limited to 'src/recode.c')
-rw-r--r--src/recode.c47
1 files changed, 46 insertions, 1 deletions
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;
}