Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

boost::format and wchar_t

I am trying to format a string using boost:

wchar_t *msg;
// fill msg
boost::format("Error: %s") % msg).str()

What I get instead of msg's content, is the address of msg in hex.

No success with things like these:

boost::format("Error: %s") % new std::wstring(msg)
boost::format("Error: %1%") % msg

Note: Even though I think it's irrelevant, but the way that I fill msg is:

FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | 40, NULL, GetLastError(), MAKELANGID(0, SUBLANG_ENGLISH_US), (LPTSTR) &msg, 512, NULL);

and Visual Studio Watch displays the content of msg correctly.

like image 699
el_shayan Avatar asked Feb 22 '12 10:02

el_shayan


1 Answers

Try using boost::wformat to work with wchar_t strings.

like image 123
wilx Avatar answered Sep 27 '22 21:09

wilx