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
GetUnicodeString(const wchar_t * unicodeString)15 inline const wchar_t* GetUnicodeString(const wchar_t* unicodeString)
16 { return unicodeString; }
GetUnicodeString(const UString & unicodeString)17 inline const UString& GetUnicodeString(const UString &unicodeString)
18 { return unicodeString; }
GetUnicodeString(const AString & ansiString)19 inline UString GetUnicodeString(const AString &ansiString)
20 { return MultiByteToUnicodeString(ansiString); }
GetUnicodeString(const AString & multiByteString,UINT codePage)21 inline UString GetUnicodeString(const AString &multiByteString, UINT codePage)
22 { return MultiByteToUnicodeString(multiByteString, codePage); }
GetUnicodeString(const wchar_t * unicodeString,UINT)23 inline const wchar_t* GetUnicodeString(const wchar_t* unicodeString, UINT)
24 { return unicodeString; }
GetUnicodeString(const UString & unicodeString,UINT)25 inline const UString& GetUnicodeString(const UString &unicodeString, UINT)
26 { return unicodeString; }
27
GetAnsiString(const char * ansiString)28 inline const char* GetAnsiString(const char* ansiString)
29 { return ansiString; }
GetAnsiString(const AString & ansiString)30 inline const AString& GetAnsiString(const AString &ansiString)
31 { return ansiString; }
GetAnsiString(const UString & unicodeString)32 inline AString GetAnsiString(const UString &unicodeString)
33 { return UnicodeStringToMultiByte(unicodeString); }
34
GetOemString(const char * oemString)35 inline const char* GetOemString(const char* oemString)
36 { return oemString; }
GetOemString(const AString & oemString)37 inline const AString& GetOemString(const AString &oemString)
38 { return oemString; }
GetOemString(const UString & unicodeString)39 inline AString GetOemString(const UString &unicodeString)
40 { return UnicodeStringToMultiByte(unicodeString, CP_OEMCP); }
41
42
43 #ifdef _UNICODE
GetSystemString(const wchar_t * unicodeString)44 inline const wchar_t* GetSystemString(const wchar_t* unicodeString)
45 { return unicodeString;}
GetSystemString(const UString & unicodeString)46 inline const UString& GetSystemString(const UString &unicodeString)
47 { return unicodeString;}
GetSystemString(const wchar_t * unicodeString,UINT)48 inline const wchar_t* GetSystemString(const wchar_t* unicodeString, UINT /* codePage */)
49 { return unicodeString;}
GetSystemString(const UString & unicodeString,UINT)50 inline const UString& GetSystemString(const UString &unicodeString, UINT /* codePage */)
51 { return unicodeString;}
GetSystemString(const AString & multiByteString,UINT codePage)52 inline UString GetSystemString(const AString &multiByteString, UINT codePage)
53 { return MultiByteToUnicodeString(multiByteString, codePage);}
GetSystemString(const AString & multiByteString)54 inline UString GetSystemString(const AString &multiByteString)
55 { return MultiByteToUnicodeString(multiByteString);}
56 #else
GetSystemString(const char * ansiString)57 inline const char* GetSystemString(const char *ansiString)
58 { return ansiString; }
GetSystemString(const AString & multiByteString,UINT)59 inline const AString& GetSystemString(const AString &multiByteString, UINT)
60 { return multiByteString; }
GetSystemString(const char * multiByteString,UINT)61 inline const char * GetSystemString(const char *multiByteString, UINT)
62 { return multiByteString; }
GetSystemString(const UString & unicodeString)63 inline AString GetSystemString(const UString &unicodeString)
64 { return UnicodeStringToMultiByte(unicodeString); }
GetSystemString(const UString & unicodeString,UINT codePage)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