summaryrefslogtreecommitdiff
path: root/extensions/source/logging/csvformatter.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-09-27 09:37:44 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-09-27 14:06:42 +0200
commit97eccc5d55d8786f91c88a0f3de36640c112e68e (patch)
treeacf3be78e6c95abd1e3c2c0881d4da1ae4dfb3c8 /extensions/source/logging/csvformatter.cxx
parentf6bf58503dda832bad97b262e4feed633fdd4853 (diff)
use more string_view in cui,extensions
Change-Id: I76253ae06af53f63206a47a84035317c6a5058b2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140637 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'extensions/source/logging/csvformatter.cxx')
-rw-r--r--extensions/source/logging/csvformatter.cxx14
1 files changed, 8 insertions, 6 deletions
diff --git a/extensions/source/logging/csvformatter.cxx b/extensions/source/logging/csvformatter.cxx
index 8e749db42831..ddbf3a9a2c36 100644
--- a/extensions/source/logging/csvformatter.cxx
+++ b/extensions/source/logging/csvformatter.cxx
@@ -97,25 +97,27 @@ namespace
return str.find_first_of(u"\",\n\r") != std::u16string_view::npos;
};
- void appendEncodedString(OUStringBuffer& buf, const OUString& str)
+ void appendEncodedString(OUStringBuffer& buf, std::u16string_view str)
{
if(needsQuoting(str))
{
// each double-quote will get replaced by two double-quotes
buf.append(quote_char);
const sal_Int32 buf_offset = buf.getLength();
- const sal_Int32 str_length = str.getLength();
+ const size_t str_length = str.size();
buf.append(str);
// special treatment for the last character
if(quote_char==str[str_length-1])
buf.append(quote_char);
// iterating backwards because the index at which we insert won't be shifted
// when moving that way.
- for(sal_Int32 i = str_length; i>=0; )
+ for(size_t i = str_length;; )
{
- i=str.lastIndexOf(quote_char, --i);
- if(i!=-1)
- buf.insert(buf_offset + i, quote_char);
+ --i;
+ i=str.substr(i).rfind(quote_char);
+ if(i==std::u16string_view::npos)
+ break;
+ buf.insert(buf_offset + i, quote_char);
}
buf.append(quote_char);
}