如何使用LOG4CXX库记录Δ字符

我的项目是多字节的,要记录的数据包含Δ字符

当我登录我像这样使用它时,

Logger::getLogger(log_name)->info(szBuf);

void info(const std::wstring& msg) const;

但是显示Δ字符?

如何正确输出?

iCMS 回答:如何使用LOG4CXX库记录Δ字符

其原因与log4cxx如何在您当前所在的语言环境中解码字符有关。?是一个替换字符,表示无法在您的当前语言环境中解码给定字符。

您可以在应用程序启动时通过以下操作对其进行修复:

std::setlocale( LC_ALL,"" ); /* Set locale for C functions */
std::locale::global(std::locale("")); /* set locale for C++ functions */

来源:https://logging.apache.org/log4cxx/latest_stable/faq.html#unicode_supported

本文链接:https://www.f2er.com/2117684.html

大家都在问