I am using boost-asio and I want to process correctly the error message.
In this example, I made a typo (1278 instead of 127):
boost::system::error_code ec;
auto address=boost::asio::ip::address::from_string("1278.0.0.1",ec);
if(ec)
{
auto text=ec.message();
//Do Something with text but what is its encoding ?
}
I get an error message and it seems to be encoded in Windows 1252 (I am using Windows 7). So it seems that the encoding is the OS encoding.
However, I was unable to find any documentation that states this fact.
Are error message in boost asio encoded with the OS character set ?
After digging into boost on my system, I found that the included hpp files include an ipp file which in turn calls the OS functions. If there is an error, only the code of the error is known at this stage.
The real error message is formed when the message() function is called.
The implementation on windows calls FormatMessageA or FormatMessageW depending if BOOST_NO_ANSI_APIS is defined:
If message calls FormatMessageW, the string is narrowed back to the system default Windows ANSI code page (CP_ACP)
In all cases on Windows the result is the default ANSI Codepage.