Reputation: 1091
Internally I can use char or wchar_t for the application internal encoding of my strings and streams. char* can hold single byte encoded data or multibyte encoded data. For example ascii and UTF-8. I could use char8_t, char16_t or char32_t to clarify the internal encoding. But these character types are not supported properly by boost locale yet. Is it save to assume that boost locale uses utf-8 as internal encoding when using std::basic_string<char>
and and std::basic_fstream<char>
and others?
Example:
// Source file is encoded in UTF-8
boost::locale generator gen;
std::locale loc = gen("de_DE.UTF-8");
std::cout.imbue(loc);
std::string text = "Die Höhle des Löwen\n"s;
std::cout << text; // Correctly handles 'ö' on all platforms.
Upvotes: 1
Views: 964
Reputation: 1071
According to this documentation yes on Windows: https://www.boost.org/doc/libs/1_74_0/libs/locale/doc/html/default_encoding_under_windows.html
On other platforms usually char *
is treated as utf-8
encoded string
Upvotes: 0