Follow the boost.log
, the sample.log was parsed as utf8. Now I want to write at windows.936, but the code below is useless.
void init_logging() {
...
std::string strCodePage = boost::locale::util::get_system_locale();//strCodePage is "zh_CN.windows-936"
std::locale loc = boost::locale::generator().generate(strCodePage);
sink->imbue(loc);
...
}
void test_wide_char_logging() {
...
const wchar_t national_chars[] = L"汉字";
BOOST_LOG(lg) << national_chars;
...
}
For example, The "汉字"
in the sample.log is 0xe6b189 0xe5ad97
, which is parsed as utf8.But I want the "汉字"
in the sample.log should be 0xbaba 0xd7d6
, which is parsed as windows-936(the same as GBK, GB2312).
Could you help me?