From 186beb241c6ec3042d1ed6145c50c4836247f62b Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Tue, 8 Jan 2013 02:44:20 -0500 Subject: [PATCH] LIB: Call FormatMessageW directly and skip an extra string encoding conversion step. --- lib/win_util.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/win_util.cpp b/lib/win_util.cpp index 7b1457d8a0..f4aa0e8997 100644 --- a/lib/win_util.cpp +++ b/lib/win_util.cpp @@ -887,22 +887,22 @@ char* windows_format_error_string( unsigned long dwError, char* pszBuf, int iSize ) { DWORD dwRet; - LPSTR lpszTemp = NULL; + LPWSTR lpszTemp = NULL; - dwRet = FormatMessageA( + dwRet = FormatMessageW( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ARGUMENT_ARRAY, NULL, dwError, LANG_NEUTRAL, - (LPSTR)&lpszTemp, + (LPWSTR)&lpszTemp, 0, NULL ); // convert from current character encoding into UTF8 - std::string encoded_message = W2A(A2W(std::string(lpszTemp))); + std::string encoded_message = W2A(std::wstring(lpszTemp)); // include the hex error code as well snprintf(pszBuf, iSize, "%s (0x%x)", encoded_message.c_str(), dwError);