简体   繁体   English

boost locale 是否支持 UTF-8 作为基于 char* 的字符串和流的内部编码

[英]Does boost locale supports UTF-8 as internal encoding for char* based strings and streams

Internally I can use char or wchar_t for the application internal encoding of my strings and streams.在内部,我可以使用 char 或 wchar_t 对我的字符串和流进行应用程序内部编码。 char* can hold single byte encoded data or multibyte encoded data. char* 可以保存单字节编码数据或多字节编码数据。 For example ascii and UTF-8.例如 ascii 和 UTF-8。 I could use char8_t, char16_t or char32_t to clarify the internal encoding.我可以使用 char8_t、char16_t 或 char32_t 来阐明内部编码。 But these character types are not supported properly by boost locale yet.但是 boost locale 还不能正确支持这些字符类型。 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?在使用std::basic_string<char>std::basic_fstream<char>等时假设 boost 语言环境使用 utf-8 作为内部编码是否可以保存?

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. 

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根据本文档,在Windows上是的: https://www.boost.org/doc/libs/1_74_0/libs/locale/doc/html/default_encoding_under_windows.ZFC35FZ30D5FCC69D2E386

On other platforms usually char * is treated as utf-8 encoded string在其他平台上,通常char *被视为utf-8编码字符串

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM