On non-Windows platforms, you can easily use char * strings and treat them as UTF-8.
The problem is that on Windows you have to receive and send messages using wchar * (W) strings. If you use the ANSI (A) functions, you will not support Unicode.
So, if you want to write a truly portable application, you need to compile it as Unicode on Windows.
Now, to keep the code clean, I would like to see what is the recommended way to work with strings, a way that minimizes ugliness in the code.
The type of strings you may need: std::string , std::wstring , std::tstring , char * , wchat_t * , TCHAR* , CString (ATL one).
Problems you may encounter:
cout/cerr/cin and their variants Unicode wcout,wcerr,wcin- all renamed wide string functions and their TCHAR macros - for example
strcmp , wcscmp and _tcscmp . - constant lines inside the code, with TCHAR you will need to populate your code with
_T() macros.
Which approach do you think is best? (examples are welcome)
Personally, I would like to use the std::tstring , but I would like to see how to do this with conversions where they are needed.
string windows cross-platform unicode tchar
sorin
source share