summaryrefslogtreecommitdiff
path: root/unotools
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-04-26 17:47:18 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-04-27 12:19:55 +0200
commitd506ff97c25b5f433aa25d8b373f1a732af493d1 (patch)
tree600e211e3426a3b43407b01d6f93e5379d608b26 /unotools
parent148f45253f75bc724804f3231a0b04b2d453e0c7 (diff)
add string_view wrappers for rtl::math::stringToDouble
Change-Id: I114bec72cb933238675e539a8388a607226827cd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133455 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'unotools')
-rw-r--r--unotools/source/i18n/localedatawrapper.cxx17
1 files changed, 4 insertions, 13 deletions
diff --git a/unotools/source/i18n/localedatawrapper.cxx b/unotools/source/i18n/localedatawrapper.cxx
index 9c4c5badabe3..24b19371a5a9 100644
--- a/unotools/source/i18n/localedatawrapper.cxx
+++ b/unotools/source/i18n/localedatawrapper.cxx
@@ -1413,22 +1413,13 @@ OUString LocaleDataWrapper::getCurr( sal_Int64 nNumber, sal_uInt16 nDecimals,
// --- number parsing -------------------------------------------------
-double LocaleDataWrapper::stringToDouble( const OUString& rString, bool bUseGroupSep,
+double LocaleDataWrapper::stringToDouble( std::u16string_view aString, bool bUseGroupSep,
rtl_math_ConversionStatus* pStatus, sal_Int32* pParseEnd ) const
{
- const sal_Unicode cGroupSep = (bUseGroupSep ? aLocaleDataItem.thousandSeparator[0] : 0);
- rtl_math_ConversionStatus eStatus = rtl_math_ConversionStatus_Ok;
- sal_Int32 nParseEnd = 0;
- double fValue = rtl::math::stringToDouble( rString, aLocaleDataItem.decimalSeparator[0], cGroupSep, &eStatus, &nParseEnd);
- bool bTryAlt = (nParseEnd < rString.getLength() && !aLocaleDataItem.decimalSeparatorAlternative.isEmpty() &&
- rString[nParseEnd] == aLocaleDataItem.decimalSeparatorAlternative.toChar());
- // Try re-parsing with alternative if that was the reason to stop.
- if (bTryAlt)
- fValue = rtl::math::stringToDouble( rString, aLocaleDataItem.decimalSeparatorAlternative.toChar(), cGroupSep, &eStatus, &nParseEnd);
- if (pStatus)
- *pStatus = eStatus;
+ const sal_Unicode* pParseEndChar;
+ double fValue = stringToDouble(aString.data(), aString.data() + aString.size(), bUseGroupSep, pStatus, &pParseEndChar);
if (pParseEnd)
- *pParseEnd = nParseEnd;
+ *pParseEnd = pParseEndChar - aString.data();
return fValue;
}