From 21a59b59d9a40ca32d91b05e62ffcd9aef8fd324 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Thu, 18 Jun 2020 16:03:38 +0300 Subject: tdf#133589 Numbertext: Use Win32API to avoid std::codecvt_utf8 bug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I45c85db44c3dfd92e0929f66c8c95cb309c91e05 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96609 Reviewed-by: László Németh Tested-by: Jenkins --- lingucomponent/source/numbertext/numbertext.cxx | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) (limited to 'lingucomponent/source') diff --git a/lingucomponent/source/numbertext/numbertext.cxx b/lingucomponent/source/numbertext/numbertext.cxx index 89f5432624bf..34e7694601a3 100644 --- a/lingucomponent/source/numbertext/numbertext.cxx +++ b/lingucomponent/source/numbertext/numbertext.cxx @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include @@ -132,26 +132,18 @@ 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 sResult = Numbertext::string2wstring(aInput.getStr()); +#endif bool result = m_aNumberText.numbertext(sResult, aLangCode.getStr()); DBG_ASSERT(result, "numbertext: false"); - OUString aResult = OUString::fromUtf8(Numbertext::wstring2string(sResult).c_str()); #if defined(_WIN32) - // workaround to fix non-BMP Unicode characters resulted by wstring limitation - if (!aScript.isEmpty() && aScript == "Hung") - { - OUStringBuffer aFix; - for (int i = 0; i < aResult.getLength(); ++i) - { - sal_Unicode c = aResult[i]; - if (0x0C80 <= c && c <= 0x0CFF) - aFix.append(sal_Unicode(0xD803)).append(sal_Unicode(c + 0xD000)); - else - aFix.append(c); - } - aResult = aFix.makeStringAndClear(); - } + OUString aResult(o3tl::toU(sResult.c_str())); +#else + OUString aResult = OUString::fromUtf8(Numbertext::wstring2string(sResult).c_str()); #endif return aResult; } -- cgit