00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef UTF8TRANSLITERATOR_H
00022 #define UTF8TRANSLITERATOR_H
00023
00024 enum scriptEnum {SE_OFF, SE_LATIN, SE_BASICLATIN, SE_BETA, SE_BGREEK, SE_GREEK, SE_HEBREW, SE_CYRILLIC, SE_ARABIC, SE_SYRIAC, SE_KATAKANA, SE_HIRAGANA, SE_JAMO, SE_HANGUL, SE_DEVANAGARI, SE_TAMIL, SE_BENGALI, SE_GURMUKHI, SE_GUJARATI, SE_ORIYA, SE_TELUGU, SE_KANNADA, SE_MALAYALAM, SE_THAI, SE_GEORGIAN, SE_ARMENIAN, SE_ETHIOPIC, SE_GOTHIC, SE_UGARITIC, SE_COPTIC, SE_HAN, SE_KANJI};
00025 #define NUMSCRIPTS 32
00026 #define NUMTARGETSCRIPTS 5
00027
00028 #include <swfilter.h>
00029 #include <swmodule.h>
00030
00031
00032
00033
00034
00035
00036 #include <unicode/unistr.h>
00037
00038
00039
00040
00041 #include <unicode/translit.h>
00042
00043
00044 #include <defs.h>
00045 #include <map>
00046
00047
00048
00049
00050 SWORD_NAMESPACE_START
00051
00052 struct SWTransData {
00053 UnicodeString resource;
00054 UTransDirection dir;
00055 };
00056 typedef std::map <const UnicodeString, SWTransData> SWTransMap;
00057 typedef std::pair<UnicodeString, SWTransData> SWTransPair;
00058
00061 class SWDLLEXPORT UTF8Transliterator : public SWFilter {
00062 private:
00063
00064 char option;
00065
00066 static const char optionstring[NUMTARGETSCRIPTS][16];
00067
00068 static const char optName[];
00069 static const char optTip[];
00070 static const char SW_RB_RULE_BASED_IDS[];
00071 static const char SW_RB_RULE[];
00072 static const char SW_RESDATA[];
00073 OptionsList options;
00074 static SWTransMap transMap;
00075 UErrorCode utf8status;
00076
00077 void Load(UErrorCode &status);
00078 void registerTrans(const UnicodeString& ID, const UnicodeString& resource, UTransDirection dir, UErrorCode &status);
00079 bool checkTrans(const UnicodeString& ID, UErrorCode &status);
00080 Transliterator *createTrans(const UnicodeString& preID, const UnicodeString& ID, const UnicodeString& postID, UTransDirection dir, UErrorCode &status);
00081
00082 public:
00083 UTF8Transliterator();
00084 virtual char processText(SWBuf &text, const SWKey *key = 0, const SWModule *module = 0);
00085 virtual const char *getOptionName() { return optName; }
00086 virtual const char *getOptionTip() { return optTip; }
00087 virtual void setOptionValue(const char *ival);
00088 virtual const char *getOptionValue();
00089 virtual OptionsList getOptionValues() { return options; }
00090 };
00091
00092 SWORD_NAMESPACE_END
00093 #endif