Commit 0251b1f0 authored by Andreas Traczyk's avatar Andreas Traczyk Committed by Ming Rui Zhang
Browse files

vcard: use utf-8 codec when streaming to/from vcard files

Change-Id: I953ae1a5bcf0b242b07e5bb9a5ec10c5155ee271
parent afeccc54
...@@ -235,7 +235,9 @@ setProfile(const std::string& accountId, ...@@ -235,7 +235,9 @@ setProfile(const std::string& accountId,
qWarning().noquote() << "Can't open file for writing: " << filePath; qWarning().noquote() << "Can't open file for writing: " << filePath;
return; return;
} }
QTextStream(&file) << QString::fromStdString(vcard); QTextStream in(&file);
in.setCodec("UTF-8");
in << QString::fromStdString(vcard);
} }
} // namespace vcard } // namespace vcard
...@@ -284,6 +286,7 @@ getAccountAvatar(const std::string& accountId) ...@@ -284,6 +286,7 @@ getAccountAvatar(const std::string& accountId)
return {}; return {};
} }
QTextStream in(&file); QTextStream in(&file);
in.setCodec("UTF-8");
const auto vCard = lrc::vCard::utils::toHashMap(in.readAll().toUtf8()); const auto vCard = lrc::vCard::utils::toHashMap(in.readAll().toUtf8());
const auto photo = (vCard.find(vCard::Property::PHOTO_PNG) == vCard.end()) ? const auto photo = (vCard.find(vCard::Property::PHOTO_PNG) == vCard.end()) ?
vCard[vCard::Property::PHOTO_JPEG] : vCard[vCard::Property::PHOTO_PNG]; vCard[vCard::Property::PHOTO_JPEG] : vCard[vCard::Property::PHOTO_PNG];
...@@ -320,6 +323,7 @@ buildContactFromProfile(const std::string & accountId, ...@@ -320,6 +323,7 @@ buildContactFromProfile(const std::string & accountId,
} }
} }
QTextStream in(&file); QTextStream in(&file);
in.setCodec("UTF-8");
QByteArray vcard = in.readAll().toUtf8(); QByteArray vcard = in.readAll().toUtf8();
const auto vCard = lrc::vCard::utils::toHashMap(vcard); const auto vCard = lrc::vCard::utils::toHashMap(vcard);
const auto alias = vCard[vCard::Property::FORMATTED_NAME]; const auto alias = vCard[vCard::Property::FORMATTED_NAME];
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment