summaryrefslogtreecommitdiff
path: root/lingucomponent
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2020-06-18 16:03:38 +0300
committerAdolfo Jayme Barrientos <fitojb@ubuntu.com>2020-06-25 13:49:40 +0200
commitdc7b1a09001638d5d6737e9bdf394f3a571ef044 (patch)
treeddc6cc812d5bc4fd04288a42682f43a955305970 /lingucomponent
parent86ed93261137e24c679baed137cc4559eb5376e4 (diff)
tdf#133589 Numbertext: Use Win32API to avoid std::codecvt_utf8 bug
(cherry picked from commit 21a59b59d9a40ca32d91b05e62ffcd9aef8fd324 and commit ad792bccc0adfdd4be75f99170a92312924d371d) Change-Id: I45c85db44c3dfd92e0929f66c8c95cb309c91e05 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96894 Tested-by: Jenkins Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
Diffstat (limited to 'lingucomponent')
-rw-r--r--lingucomponent/source/numbertext/numbertext.cxx17
1 files changed, 13 insertions, 4 deletions
diff --git a/lingucomponent/source/numbertext/numbertext.cxx b/lingucomponent/source/numbertext/numbertext.cxx
index bc13530d5250..556dc2ea7a90 100644
--- a/lingucomponent/source/numbertext/numbertext.cxx
+++ b/lingucomponent/source/numbertext/numbertext.cxx
@@ -22,6 +22,7 @@
#include <osl/file.hxx>
#include <tools/debug.hxx>
+#include <o3tl/char16_t2wchar_t.hxx>
#include <sal/config.h>
#include <cppuhelper/factory.hxx>
@@ -144,12 +145,20 @@ OUString SAL_CALL NumberText_Impl::getNumberText(const OUString& rText, const Lo
if (!aCountry.isEmpty())
aCode += "-" + aCountry;
OString aLangCode(OUStringToOString(aCode, RTL_TEXTENCODING_ASCII_US));
+#if defined(_WIN32)
+ std::wstring sResult(o3tl::toW(rText.getStr()));
+#else
OString aInput(OUStringToOString(rText, RTL_TEXTENCODING_UTF8));
- std::wstring aResult = Numbertext::string2wstring(aInput.getStr());
- bool result = m_aNumberText.numbertext(aResult, aLangCode.getStr());
+ std::wstring sResult = Numbertext::string2wstring(aInput.getStr());
+#endif
+ bool result = m_aNumberText.numbertext(sResult, aLangCode.getStr());
DBG_ASSERT(result, "numbertext: false");
- OString aResult2(Numbertext::wstring2string(aResult).c_str());
- return OUString::fromUtf8(aResult2);
+#if defined(_WIN32)
+ OUString aResult(o3tl::toU(sResult.c_str()));
+#else
+ OUString aResult = OUString::fromUtf8(Numbertext::wstring2string(sResult).c_str());
+#endif
+ return aResult;
#else
return rText;
#endif