summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-07-23 14:42:17 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-07-23 14:42:17 +0300
commit5c9aaa12bbe0fb884f5f3ebae793002f19359acb (patch)
tree3cdb8ed6aec246ee29ac782180eae6df4288503b
parentf14f74020efd2b74eb8c2b454d1f80f1b56a91fe (diff)
fixes #1510 (The import feature sometimes converts fields from unicode to string, losing information)
-rw-r--r--src/mir_app/src/MDatabaseCommon.cpp21
1 files changed, 4 insertions, 17 deletions
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;