From 5c9aaa12bbe0fb884f5f3ebae793002f19359acb Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 23 Jul 2018 14:42:17 +0300 Subject: fixes #1510 (The import feature sometimes converts fields from unicode to string, losing information) --- src/mir_app/src/MDatabaseCommon.cpp | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) (limited to 'src/mir_app') diff --git a/src/mir_app/src/MDatabaseCommon.cpp b/src/mir_app/src/MDatabaseCommon.cpp index 6eb0e0582a..bbe5f27877 100644 --- a/src/mir_app/src/MDatabaseCommon.cpp +++ b/src/mir_app/src/MDatabaseCommon.cpp @@ -205,24 +205,11 @@ STDMETHODIMP_(BOOL) MDatabaseCommon::GetContactSetting(MCONTACT contactID, LPCST return 1; if (dbv->type == DBVT_UTF8) { - WCHAR *tmp = nullptr; - char *p = NEWSTR_ALLOCA(dbv->pszVal); - if (mir_utf8decode(p, &tmp) != nullptr) { - BOOL bUsed = FALSE; - int result = WideCharToMultiByte(m_codePage, WC_NO_BEST_FIT_CHARS, tmp, -1, nullptr, 0, nullptr, &bUsed); - + wchar_t *tmp = mir_utf8decodeW(dbv->pszVal); + if (tmp != nullptr) { mir_free(dbv->pszVal); - - if (bUsed || result == 0) { - dbv->type = DBVT_WCHAR; - dbv->pwszVal = tmp; - } - else { - dbv->type = DBVT_ASCIIZ; - dbv->pszVal = (char *)mir_alloc(result); - WideCharToMultiByte(m_codePage, WC_NO_BEST_FIT_CHARS, tmp, -1, dbv->pszVal, result, nullptr, nullptr); - mir_free(tmp); - } + dbv->type = DBVT_WCHAR; + dbv->pwszVal = tmp; } else { dbv->type = DBVT_ASCIIZ; -- cgit v1.2.3