1

在内部,我可以使用 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. 
4

1 回答 1

0

根据此文档,在Windows上是: https ://www.boost.org/doc/libs/1_74_0/libs/locale/doc/html/default_encoding_under_windows.html

在其他平台上通常char *被视为utf-8编码字符串

于 2020-12-07T14:07:43.717 回答