Home | History | Annotate | Download | only in Common
      1 // Common/StringConvert.h
      2 
      3 #ifndef __COMMON_STRING_CONVERT_H
      4 #define __COMMON_STRING_CONVERT_H
      5 
      6 #include "MyWindows.h"
      7 #include "MyString.h"
      8 #include "Types.h"
      9 
     10 UString MultiByteToUnicodeString(const AString &srcString, UINT codePage = CP_ACP);
     11 AString UnicodeStringToMultiByte(const UString &srcString, UINT codePage, char defaultChar, bool &defaultCharWasUsed);
     12 AString UnicodeStringToMultiByte(const UString &srcString, UINT codePage = CP_ACP);
     13 
     14 
     15 inline const wchar_t* GetUnicodeString(const wchar_t* unicodeString)
     16   { return unicodeString; }
     17 inline const UString& GetUnicodeString(const UString &unicodeString)
     18   { return unicodeString; }
     19 inline UString GetUnicodeString(const AString &ansiString)
     20   { return MultiByteToUnicodeString(ansiString); }
     21 inline UString GetUnicodeString(const AString &multiByteString, UINT codePage)
     22   { return MultiByteToUnicodeString(multiByteString, codePage); }
     23 inline const wchar_t* GetUnicodeString(const wchar_t* unicodeString, UINT)
     24   { return unicodeString; }
     25 inline const UString& GetUnicodeString(const UString &unicodeString, UINT)
     26   { return unicodeString; }
     27 
     28 inline const char* GetAnsiString(const char* ansiString)
     29   { return ansiString; }
     30 inline const AString& GetAnsiString(const AString &ansiString)
     31   { return ansiString; }
     32 inline AString GetAnsiString(const UString &unicodeString)
     33   { return UnicodeStringToMultiByte(unicodeString); }
     34 
     35 inline const char* GetOemString(const char* oemString)
     36   { return oemString; }
     37 inline const AString& GetOemString(const AString &oemString)
     38   { return oemString; }
     39 inline AString GetOemString(const UString &unicodeString)
     40   { return UnicodeStringToMultiByte(unicodeString, CP_OEMCP); }
     41 
     42 
     43 #ifdef _UNICODE
     44   inline const wchar_t* GetSystemString(const wchar_t* unicodeString)
     45     { return unicodeString;}
     46   inline const UString& GetSystemString(const UString &unicodeString)
     47     { return unicodeString;}
     48   inline const wchar_t* GetSystemString(const wchar_t* unicodeString, UINT /* codePage */)
     49     { return unicodeString;}
     50   inline const UString& GetSystemString(const UString &unicodeString, UINT /* codePage */)
     51     { return unicodeString;}
     52   inline UString GetSystemString(const AString &multiByteString, UINT codePage)
     53     { return MultiByteToUnicodeString(multiByteString, codePage);}
     54   inline UString GetSystemString(const AString &multiByteString)
     55     { return MultiByteToUnicodeString(multiByteString);}
     56 #else
     57   inline const char* GetSystemString(const char *ansiString)
     58     { return ansiString; }
     59   inline const AString& GetSystemString(const AString &multiByteString, UINT)
     60     { return multiByteString; }
     61   inline const char * GetSystemString(const char *multiByteString, UINT)
     62     { return multiByteString; }
     63   inline AString GetSystemString(const UString &unicodeString)
     64     { return UnicodeStringToMultiByte(unicodeString); }
     65   inline AString GetSystemString(const UString &unicodeString, UINT codePage)
     66     { return UnicodeStringToMultiByte(unicodeString, codePage); }
     67 #endif
     68 
     69 #ifndef UNDER_CE
     70 AString SystemStringToOemString(const CSysString &srcString);
     71 #endif
     72 
     73 #endif
     74