Menu

#12 windows Connection::getErrorString result is Garbled

open
nobody
None
5
2011-03-03
2011-03-03
Anonymous
No

for windows 处理 windows 下获得错误信息乱码的问题
ulxr_connection.cpp 文件 第 613 行 getErrorString 函数改为

ULXR_API_IMPL(CppString) Connection::getErrorString(int err_number)
{
#ifdef __WIN32__
LPSTR lpMsgBuf;
#if defined (ULXR_UNICODE) || defined(ULXR_UNICODE_ONLY_HELPERS)
int ok = FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
err_number,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPWSTR)&lpMsgBuf,
0,
NULL);
# else
int ok = FormatMessageA(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
err_number,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPSTR)&lpMsgBuf,
0,
NULL);
#endif
if (ok != 0 && lpMsgBuf != 0)
return ULXR_GET_STRING(lpMsgBuf);
else
{
char s[40];
CppString errn = ULXR_GET_STRING(itoa(err_number, s, 10));
return ulxr_i18n(ULXR_PCHAR("Unknown connection problem, Windows error code: #"))+errn;
}
#else
return(getLastErrorString(err_number));
#endif
}

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.