00001 /******************************************************************************* 00002 * 00003 * Copyright (C) 1998-1999, International Business Machines 00004 * Corporation and others. All Rights Reserved. 00005 * 00006 *******************************************************************************/ 00007 00008 #ifndef CONVERT_H 00009 #define CONVERT_H 00010 00011 00012 #include "unicode/unistr.h" 00013 #include "unicode/ucnv.h" 00014 00015 class U_COMMON_API UnicodeConverterCPP 00016 { 00017 private: 00018 /*Internal Data representation of the Converter*/ 00019 UConverter* myUnicodeConverter; 00020 /*Debug method*/ 00021 void printRef(void) const; 00022 00023 /* list of converter and alias names */ 00024 static const char **availableConverterNames; 00025 static int32_t availableConverterNamesCount; 00026 00027 public: 00028 00029 //Constructors and a destructor 00030 00036 UnicodeConverterCPP(); 00037 00048 UnicodeConverterCPP(const char* name, 00049 UErrorCode& err); 00050 00062 UnicodeConverterCPP(const UnicodeString& name, 00063 UErrorCode& err); 00064 00074 UnicodeConverterCPP(int32_t codepageNumber, 00075 UConverterPlatform platform, 00076 UErrorCode& err); 00077 00078 ~UnicodeConverterCPP(); 00079 00080 00095 void fromUnicodeString(char* target, 00096 int32_t& targetSize, 00097 const UnicodeString& source, 00098 UErrorCode& err) const; 00099 00113 void toUnicodeString(UnicodeString& target, 00114 const char* source, 00115 int32_t sourceSize, 00116 UErrorCode& err) const; 00117 00138 void fromUnicode(char*& target, 00139 const char* targetLimit, 00140 const UChar*& source, 00141 const UChar* sourceLimit, 00142 int32_t * offsets, 00143 UBool flush, 00144 UErrorCode& err); 00145 00146 00166 void toUnicode(UChar*& target, 00167 const UChar* targetLimit, 00168 const char*& source, 00169 const char* sourceLimit, 00170 int32_t * offsets, 00171 UBool flush, 00172 UErrorCode& err); 00173 00174 00180 int8_t getMaxBytesPerChar(void) const; 00181 00188 int8_t getMinBytesPerChar(void) const; 00189 00196 UConverterType getType(void) const; 00197 00210 void getStarters(UBool starters[256], 00211 UErrorCode& err) const; 00222 void getSubstitutionChars(char* subChars, 00223 int8_t& len, 00224 UErrorCode& err) const; 00236 void setSubstitutionChars(const char* subChars, 00237 int8_t len, 00238 UErrorCode& err); 00239 00245 void resetState(void); 00246 00255 const char* getName( UErrorCode& err) const; 00256 00257 00268 int32_t getCodepage(UErrorCode& err) const; 00269 00277 UConverterToUCallback getMissingCharAction(void) const; 00278 00286 UConverterFromUCallback getMissingUnicodeAction(void) const; 00287 00294 void setMissingCharAction(UConverterToUCallback action, 00295 UErrorCode& err); 00296 00305 void setMissingUnicodeAction(UConverterFromUCallback action, 00306 UErrorCode& err); 00314 void getDisplayName(const Locale& displayLocale, 00315 UnicodeString& displayName) const; 00316 00324 UConverterPlatform getCodepagePlatform(UErrorCode& err) const; 00325 00326 00327 UnicodeConverterCPP& operator=(const UnicodeConverterCPP& that); 00328 UBool operator==(const UnicodeConverterCPP& that) const; 00329 UBool operator!=(const UnicodeConverterCPP& that) const; 00330 UnicodeConverterCPP(const UnicodeConverterCPP& that); 00331 00339 static const char* const* getAvailableNames(int32_t& num, 00340 UErrorCode& err); 00341 00347 static int32_t flushCache(void); 00358 void fixFileSeparator(UnicodeString& source) const; 00359 00367 UBool isAmbiguous(void) const; 00368 00369 }; 00370 #endif