At my company we have a cross platform(Linux & Windows) library that contains our own extension of the STL std::string, this class provides all sort of functionality on top
No, there is no way to make Windows treat "narrow" strings as UTF-8.
Here is what works best for me in this situation (cross-platform application that has Windows and Linux builds).
Other approaches that I tried but don't like much:
typedef std::basic_string tstring;
then use tstring in the business code. Wrappers/overloads can be made to streamline conversion between std::string and std::tstring, but it still adds a lot of pain.std::wstring
everywhere. Does not help much since wchar_t
is 16 bit on Windows, so you either have to restrict yourself to BMP or go to a lot of complications to make the code dealing with Unicode cross-platform. In the latter case, all benefits over UTF-8 evaporate.CString
in the platfrom-specific portion; use std::string
in cross-platfrom portion. This is actually a variant of what I recommend above. CString
is in many aspects superior to std::string
(in my opinion). But it introduces an additional dependency and thus not always acceptable or convenient.