misc/libphysfs/lzma/CPP/Common/StringConvert.h
changeset 12218 bb5522e88ab2
equal deleted inserted replaced
12217:ea891871f481 12218:bb5522e88ab2
       
     1 // Common/StringConvert.h
       
     2 
       
     3 #ifndef __COMMON_STRINGCONVERT_H
       
     4 #define __COMMON_STRINGCONVERT_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 = CP_ACP);
       
    12 
       
    13 inline const wchar_t* GetUnicodeString(const wchar_t* unicodeString)
       
    14   { return unicodeString; }
       
    15 inline const UString& GetUnicodeString(const UString &unicodeString)
       
    16   { return unicodeString; }
       
    17 inline UString GetUnicodeString(const AString &ansiString)
       
    18   { return MultiByteToUnicodeString(ansiString); }
       
    19 inline UString GetUnicodeString(const AString &multiByteString, UINT codePage)
       
    20   { return MultiByteToUnicodeString(multiByteString, codePage); }
       
    21 inline const wchar_t* GetUnicodeString(const wchar_t* unicodeString, UINT)
       
    22   { return unicodeString; }
       
    23 inline const UString& GetUnicodeString(const UString &unicodeString, UINT)
       
    24   { return unicodeString; }
       
    25 
       
    26 inline const char* GetAnsiString(const char* ansiString)
       
    27   { return ansiString; }
       
    28 inline const AString& GetAnsiString(const AString &ansiString)
       
    29   { return ansiString; }
       
    30 inline AString GetAnsiString(const UString &unicodeString)
       
    31   { return UnicodeStringToMultiByte(unicodeString); }
       
    32 
       
    33 inline const char* GetOemString(const char* oemString)
       
    34   { return oemString; }
       
    35 inline const AString& GetOemString(const AString &oemString)
       
    36   { return oemString; }
       
    37 inline AString GetOemString(const UString &unicodeString)
       
    38   { return UnicodeStringToMultiByte(unicodeString, CP_OEMCP); }
       
    39 
       
    40 
       
    41 #ifdef _UNICODE
       
    42   inline const wchar_t* GetSystemString(const wchar_t* unicodeString)
       
    43     { return unicodeString;}
       
    44   inline const UString& GetSystemString(const UString &unicodeString)
       
    45     { return unicodeString;}
       
    46   inline const wchar_t* GetSystemString(const wchar_t* unicodeString, UINT /* codePage */)
       
    47     { return unicodeString;}
       
    48   inline const UString& GetSystemString(const UString &unicodeString, UINT /* codePage */)
       
    49     { return unicodeString;}
       
    50   inline UString GetSystemString(const AString &multiByteString, UINT codePage)
       
    51     { return MultiByteToUnicodeString(multiByteString, codePage);}
       
    52   inline UString GetSystemString(const AString &multiByteString)
       
    53     { return MultiByteToUnicodeString(multiByteString);}
       
    54 #else
       
    55   inline const char* GetSystemString(const char *ansiString)
       
    56     { return ansiString; }
       
    57   inline const AString& GetSystemString(const AString &multiByteString, UINT)
       
    58     { return multiByteString; }
       
    59   inline const char * GetSystemString(const char *multiByteString, UINT)
       
    60     { return multiByteString; }
       
    61   inline AString GetSystemString(const UString &unicodeString)
       
    62     { return UnicodeStringToMultiByte(unicodeString); }
       
    63   inline AString GetSystemString(const UString &unicodeString, UINT codePage)
       
    64     { return UnicodeStringToMultiByte(unicodeString, codePage); }
       
    65 #endif
       
    66 
       
    67 #ifndef _WIN32_WCE
       
    68 AString SystemStringToOemString(const CSysString &srcString);
       
    69 #endif
       
    70 
       
    71 #endif