From 94ca629ceec7b0dc9f6f724b2e15923d3ec1d5b3 Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Fri, 5 Aug 2005 03:06:50 +0000 Subject: Language AutoDetection Improvements - Fix: Loading/Saving range options. - Fix: Language AutoDetection. Using locale language instead of selected one. - Support for range options in GTK UI. - Option to control recoding timeout is provided. - LibRCC.h is updated (Translate, Spell, IConv). - Documentation is updated. - Add 'rcc-config' alias to 'rcc-gtk2-config' in spec. - Implemented concept of parrent languages + The concept is used in language autodetection. The string in considered language is permited to have words from all it's parrent languages. + English is assumed to be parrent for all other languages by default. + Russian is parrent language for Ukrainian and Belorussian. - No translation to english if translation between related (one of the languages is parrent for another one) languages is failed. --- src/rccstring.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/rccstring.c') diff --git a/src/rccstring.c b/src/rccstring.c index aa92407..0f46c90 100644 --- a/src/rccstring.c +++ b/src/rccstring.c @@ -175,3 +175,26 @@ int rccIsASCII(const char *str) { if ((unsigned char)str[i]>0x7F) return 0; return 1; } + +size_t rccStringSizedGetChars(const char *str, size_t size) { + size_t i, skip = 0, chars = 0; + const unsigned char *tmp; + + tmp = rccGetString(str); + + for (i=0;(size?(size-i):tmp[i]);i++) { + if (skip) { + skip--; + continue; + } + + if (tmp[i]<0x80) skip = 0; + else if ((tmp[i]>0xBF)&&(tmp[i]<0xE0)) skip = 1; + else if ((tmp[i]>0xDF)&&(tmp[i]<0xF0)) skip = 2; + else if ((tmp[i]>0xEF)&&(tmp[i]<0xF8)) skip = 3; + else skip = 4; + chars++; + } + + return chars; +} -- cgit v1.2.3