Reputation: 5791
I have a large existing Win32 C++ code-base, and I want to make it portable so that it compiles and runs on both Windows (MSCV) and Linux (gcc).
For a new project I would try to go UTF-8 Everywhere, but this existing code-base already stores and processes its text in std::wstring
as UTF-16.
So I expect to cause less upheaval, and have less risk of breaking existing behavior on Windows, if I keep it that way and try to work with it.
So this is what text handling would look like once the code-base is cross-platform:
std::wstring
/wchar_t
.#ifdef
s to do the correct thing on both platforms.What are the downsides/problems of this approach?
Problems I already considered:
Higher memory usage compared to UTF-8.
Per-code-unit processing like std::tolower
will behave differently on the two platforms if there are Unicode codepoints outside the Basic Multilingual Plane.
Some std::wstring
-accepting overloads used by the current code-base, such as the std::ifstream(std::wstring, ...)
constructor, are actually Microsoft-specific extensions and not available on Linux/GCC - so extra platform-specific #ifdef
s will be necessary in those places.
But aside from that?
Upvotes: 0
Views: 147