From 2ae73cb39c445e7edd2f31c60d4ddec95354114b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Turnel?= Date: Mon, 28 May 2018 10:26:43 +0200 Subject: [PATCH] Changed charset conversion function from 'any to any' to 'any to utf8' Update bctoolbox for this commit to work --- include/linphone/utils/utils.h | 2 +- src/chat/chat-message/chat-message.cpp | 2 +- src/utils/utils.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/linphone/utils/utils.h b/include/linphone/utils/utils.h index c39d64e72..b4675af0c 100644 --- a/include/linphone/utils/utils.h +++ b/include/linphone/utils/utils.h @@ -129,7 +129,7 @@ namespace Utils { LINPHONE_PUBLIC std::string localeToUtf8 (const std::string &str); LINPHONE_PUBLIC std::string utf8ToLocale (const std::string &str); - LINPHONE_PUBLIC std::string convertString (const std::string &str, const std::string &from, const std::string &to); + LINPHONE_PUBLIC std::string convertAnyToUtf8 (const std::string &str, const std::string &encoding); } LINPHONE_END_NAMESPACE diff --git a/src/chat/chat-message/chat-message.cpp b/src/chat/chat-message/chat-message.cpp index ff2a48399..3017bd233 100644 --- a/src/chat/chat-message/chat-message.cpp +++ b/src/chat/chat-message/chat-message.cpp @@ -457,7 +457,7 @@ static void forceUtf8Content (Content &content) { charset = charset.substr(begin, end - begin); if (Utils::stringToLower(charset) != "utf-8") { - string utf8Body = Utils::convertString(content.getBodyAsUtf8String(), charset, "UTF-8"); + string utf8Body = Utils::convertAnyToUtf8(content.getBodyAsUtf8String(), charset); if (!utf8Body.empty()) { // TODO: use move operator if possible in the future! content.setBodyFromUtf8(utf8Body); diff --git a/src/utils/utils.cpp b/src/utils/utils.cpp index b05174a63..14de24c8d 100644 --- a/src/utils/utils.cpp +++ b/src/utils/utils.cpp @@ -243,8 +243,8 @@ string Utils::utf8ToLocale (const string &str) { return localeStr; } -string Utils::convertString (const string &str, const string &from, const string &to) { - char *cStr = bctbx_convert_from_to(str.c_str(), from.c_str(), to.c_str()); +string Utils::convertAnyToUtf8 (const string &str, const string &encoding) { + char *cStr = bctbx_convert_any_to_utf8(str.c_str(), encoding.c_str()); string convertedStr = cStringToCppString(cStr); bctbx_free(cStr); return convertedStr;