Reputation: 840
Is it possible to log std::wstring
with the Poco Logger?
Like in this short example:
int main(int argc, char** argv)
{
Logger& logger = Logger::get("Testlogger");
std::wstring WStringMessage = L"Message as a WString";
std::string StringMessage = "Message as a String";
//logger.information(WStringMessage); //Did not compile because it only takes a String
logger.information(StringMessage);
system("PAUSE");
return 0;
}
Is there a possible Solution or did i have to convert every std::wstring
to a std::string
?
And how is the std::wstring
Support in other Poco Libraries like the XML one?
Upvotes: 0
Views: 918
Reputation: 5330
Poco interfaces are utf-8 only, so you will have to convert the string to utf-8 before sending it to the logger:
std::string msg;
Poco::UnicodeConverter::convert(WStringMessage, msg);
logger.information(msg);
For XML, see here, but basically the recomendation is the same - use utf-8.
Upvotes: 1