diff options
Diffstat (limited to 'sal')
-rw-r--r-- | sal/qa/rtl/math/test-rtl-math.cxx | 8 | ||||
-rw-r--r-- | sal/rtl/strtmpl.hxx | 8 |
2 files changed, 12 insertions, 4 deletions
diff --git a/sal/qa/rtl/math/test-rtl-math.cxx b/sal/qa/rtl/math/test-rtl-math.cxx index 57ac2a2616f0..05879d567760 100644 --- a/sal/qa/rtl/math/test-rtl-math.cxx +++ b/sal/qa/rtl/math/test-rtl-math.cxx @@ -328,6 +328,14 @@ public: '.', aGroups, ',', true); CPPUNIT_ASSERT_EQUAL( OUString("1,000"), aRes); + // Check non-ASCII separators: Arabic decimal separator U+066B, thousand separator U+066C + fVal = 123456.78; + aRes = rtl::math::doubleToUString( fVal, + rtl_math_StringFormat_Automatic, + 2, + u'٫', aGroups, u'٬', true); + CPPUNIT_ASSERT_EQUAL( OUString(u"1٬23٬456٫78"), aRes); + fVal = 4503599627370495.0; aRes = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_Automatic, diff --git a/sal/rtl/strtmpl.hxx b/sal/rtl/strtmpl.hxx index cbbef030198f..eece825ec082 100644 --- a/sal/rtl/strtmpl.hxx +++ b/sal/rtl/strtmpl.hxx @@ -1416,7 +1416,7 @@ void doubleToString(rtl_tString** pResult, sal_Int32* pResultCapacity, sal_Int32 return (n + d / 2) / d * d; }; - auto append = [](rtl_tString** s, sal_Int32* pCapacity, sal_Int32 rOffset, std::string_view sv) + auto append = [](rtl_tString** s, sal_Int32* pCapacity, sal_Int32 rOffset, auto sv) { if (!pCapacity) newFromStr_WithLength(s, sv.data(), sv.size()); @@ -1569,8 +1569,8 @@ void doubleToString(rtl_tString** pResult, sal_Int32* pResultCapacity, sal_Int32 // max(nDigits) = max(nDecPlaces) + 1 + max(nExp) + 1 = 20 + 1 + 308 + 1 = 330 // max(nBuf) = max(nDigits) + max(nDecPlaces) + 10 + max(nDigits) * 2 = 330 * 3 + 20 + 10 = 1020 assert(nBuf <= 1024); - char* const pBuf = static_cast<char*>(alloca(nBuf)); - char* p = pBuf; + auto* const pBuf = static_cast<Char_T<rtl_tString>*>(alloca(nBuf * sizeof(Char_T<rtl_tString>))); + auto* p = pBuf; if (bSign) *p++ = '-'; @@ -1718,7 +1718,7 @@ void doubleToString(rtl_tString** pResult, sal_Int32* pResultCapacity, sal_Int32 *p++ = nExp % 10 + '0'; } - append(pResult, pResultCapacity, nResultOffset, std::string_view(pBuf, p - pBuf)); + append(pResult, pResultCapacity, nResultOffset, std::basic_string_view(pBuf, p - pBuf)); } template <sal_Int32 maxLen, typename C, typename T> sal_Int32 SAL_CALL valueOfFP(C* pStr, T f) |