summaryrefslogtreecommitdiffstats
path: root/lingucomponent
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2020-06-18 16:03:38 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2020-06-18 17:44:49 +0200
commit21a59b59d9a40ca32d91b05e62ffcd9aef8fd324 (patch)
treee0167329d9d1046d83c02ead754c436bdcec7135 /lingucomponent
parentsw: try not to layout in SwShellTableCursor::FillRects() (diff)
downloadcore-21a59b59d9a40ca32d91b05e62ffcd9aef8fd324.tar.gz
core-21a59b59d9a40ca32d91b05e62ffcd9aef8fd324.zip
tdf#133589 Numbertext: Use Win32API to avoid std::codecvt_utf8 bug
Change-Id: I45c85db44c3dfd92e0929f66c8c95cb309c91e05 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96609 Reviewed-by: László Németh <nemeth@numbertext.org> Tested-by: Jenkins
Diffstat (limited to 'lingucomponent')
-rw-r--r--lingucomponent/source/numbertext/numbertext.cxx24
1 files changed, 8 insertions, 16 deletions
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 <osl/file.hxx>
#include <tools/debug.hxx>
-#include <rtl/ustrbuf.hxx>
+#include <o3tl/char16_t2wchar_t.hxx>
#include <sal/config.h>
#include <cppuhelper/factory.hxx>
@@ -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;
}