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