From e5158b1b3c71329732dd3625f2ec048c9316df7f Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 17 Mar 2020 22:52:32 +0300 Subject: Jabber: fix for Chinese in error messages --- protocols/JabberG/src/jabber_message_handlers.cpp | 16 +++++++++------- protocols/JabberG/src/jabber_util.cpp | 5 ++--- 2 files changed, 11 insertions(+), 10 deletions(-) (limited to 'protocols/JabberG/src') diff --git a/protocols/JabberG/src/jabber_message_handlers.cpp b/protocols/JabberG/src/jabber_message_handlers.cpp index eb00c11636..f0002ddeac 100644 --- a/protocols/JabberG/src/jabber_message_handlers.cpp +++ b/protocols/JabberG/src/jabber_message_handlers.cpp @@ -38,14 +38,16 @@ bool CJabberProto::OnMessageError(const TiXmlElement *node, ThreadData*, CJabber if (id != -1) ProtoBroadcastAck(pInfo->GetHContact(), ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)id, (LPARAM)szErrText.c_str()); else { - wchar_t buf[512]; - auto *body = XmlGetChildText(node, "body"); - if (body) - mir_snwprintf(buf, L"%s:\n%s\n%s", pInfo->GetFrom(), body, szErrText.c_str()); - else - mir_snwprintf(buf, L"%s:\n%s", pInfo->GetFrom(), szErrText.c_str()); + CMStringW wszErrorText(Utf2T(pInfo->GetFrom())); + wszErrorText.Append(L":\n"); - MsgPopup(0, buf, TranslateT("Error")); + if (auto *body = XmlGetChildText(node, "body")) { + wszErrorText.Append(Utf2T(body)); + wszErrorText.AppendChar('\n'); + } + + wszErrorText += szErrText; + MsgPopup(0, wszErrorText, TranslateT("Error")); } } return true; diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp index 6e69251042..ec09d029ec 100755 --- a/protocols/JabberG/src/jabber_util.cpp +++ b/protocols/JabberG/src/jabber_util.cpp @@ -284,10 +284,9 @@ CMStringW JabberErrorMsg(const TiXmlElement *errorNode, int *pErrorCode) } } + ret.Format(L"%s %d: %s", TranslateT("Error"), errorCode, TranslateW(JabberErrorStr(errorCode))); if (str != nullptr) - ret.Format(L"%s %d: %s\r\n%s", TranslateT("Error"), errorCode, TranslateW(JabberErrorStr(errorCode)), Utf2T(str).get()); - else - ret.Format(L"%s %d: %s", TranslateT("Error"), errorCode, TranslateW(JabberErrorStr(errorCode))); + ret.AppendFormat(L"\r\n%s", Utf2T(str).get()); if (pErrorCode) *pErrorCode = errorCode; -- cgit v1.2.3