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