在内部,我可以使用 char 或 wchar_t 对我的字符串和流进行应用程序内部编码。char* 可以保存单字节编码数据或多字节编码数据。例如 ascii 和 UTF-8。我可以使用 char8_t、char16_t 或 char32_t 来阐明内部编码。但是 boost locale 还不能正确支持这些字符类型。假设 boost locale 在使用std::basic_string<char>
and and and std::basic_fstream<char>
and others 时使用 utf-8 作为内部编码是否可以节省?
例子:
// 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.