CString simply is an alias for CStringT<TCHAR, ...>.TCHAR is defined as either wchar_t or char, depending on whether you project is configured with the Unicode or Multi-Byte character set.CStringA and CStringW that are defined as CStringT<char, ...> and CStringT<wchar_t, ...>, respectively.char-based strings use whatever character-encoding is configured as "ANSI" Codepage on the system where the program runs.wchar_t-based strings typically use Unicode character set with UTF-16 encoding. At least on Windows.
wchar_t is 16-Bit in size (per character), UTF-16 is typically used for "Unicode" strings.std::string simply is a wrapper for a sequence of char's. It can store whatever "multi-byte" character encoding that you like 😄char-strings assume the "ANSI" Codepage configured on the local system.GetACP() to detect the "ANSI" Codepage that is configured on the current system...char-based on wchar_t-based strings, see here: |
|
CString actually CStringT<char> or CStringT<whcar_t>?std::string to be encoded in? Latin-1? UTF-8? User's local "ANSI" codepage?
| What is the encoding of CString? |
|
|
CStringW, assuming that it contains an Unicode string, in UTF-16 encoding.You can then get a C string from that CString, which can then be plugged into creating a C++ std::string. |
| How can we get a C String from a CStringT<wchar_t>??? as far as I know, its not possible!! |
<Windows.h>, or by something that implicitly gets included when <Windows.h> is included.<Windows.h> anyway, for WideCharToMultiByte() function.GetACP() function.
|
|
CP_UTF8 means UTF-8.CP_ACP means "whatever happens to be configured as the 'ANSI' Codepage on the local machine"CP_ACP probably is Windows-1252, but it can be changed in the Windows control panel to something else.| what would be the code to convert std::string to CStringW? |
WideCharToMultiByte(), you will probably figure it out... |
|