use more string view in linguistic

Change-Id: Ib5c776f95b424128871a1676d996ae95b7048c64
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164016
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2024-02-27 11:02:45 +02:00
parent 607740654f
commit e6328c4600
2 changed files with 5 additions and 4 deletions

View file

@ -133,7 +133,7 @@ LNG_DLLPUBLIC bool IsUpper( const OUString &rText, sal_Int32 nPos, sal_In
inline bool IsUpper( const OUString &rText, LanguageType nLanguage ) { return IsUpper( rText, 0, rText.getLength(), nLanguage ); }
LNG_DLLPUBLIC CapType capitalType(const OUString&, CharClass const *);
LNG_DLLPUBLIC bool HasDigits( const OUString &rText );
LNG_DLLPUBLIC bool HasDigits( std::u16string_view rText );
LNG_DLLPUBLIC bool IsNumeric( std::u16string_view rText );

View file

@ -42,6 +42,7 @@
#include <unotools/localedatawrapper.hxx>
#include <svtools/strings.hrc>
#include <unotools/resmgr.hxx>
#include <o3tl/string_view.hxx>
#include <linguistic/misc.hxx>
#include <linguistic/hyphdta.hxx>
@ -625,14 +626,14 @@ const sal_uInt32 the_aDigitZeroes [] =
0x0001D7CE //1D7FF ; Decimal # Nd [50] MATHEMATICAL BOLD DIGIT ZERO..MATHEMATICAL MONOSPACE DIGIT NINE
};
bool HasDigits( const OUString &rText )
bool HasDigits( std::u16string_view rText )
{
const sal_Int32 nLen = rText.getLength();
const sal_Int32 nLen = rText.size();
sal_Int32 i = 0;
while (i < nLen) // for all characters ...
{
const sal_uInt32 nCodePoint = rText.iterateCodePoints( &i ); // handle unicode surrogates correctly...
const sal_uInt32 nCodePoint = o3tl::iterateCodePoints( rText, &i ); // handle unicode surrogates correctly...
for (unsigned int nDigitZero : the_aDigitZeroes) // ... check in all 0..9 ranges
{
if (nDigitZero > nCodePoint)