summaryrefslogtreecommitdiff
path: root/include/comphelper/string.hxx
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2023-05-05 09:46:52 +0200
committerStephan Bergmann <sbergman@redhat.com>2023-05-05 11:30:12 +0200
commit28cc0bff10f5dcec0c7b698ae7ba275845b2cad1 (patch)
treecdcccaa2356b8bea6c5b919faa6cd497a72e2336 /include/comphelper/string.hxx
parentc1bd421eae5449a005f2ee0f01b3b4e72002296e (diff)
Break comphelper::adjustIndexToStartOfSurrogate out of o3tl::iterateCodePoints
...as what they do is orthogonal (and it turned out that the use case that motivated the addition of o3tl::iterateCodePoints in the first place needs them independently, anyway) Change-Id: Id33901a2f7ac627253654ee6d883305dcf5a456f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151415 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'include/comphelper/string.hxx')
-rw-r--r--include/comphelper/string.hxx13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/comphelper/string.hxx b/include/comphelper/string.hxx
index 38564bc16673..8144a7e95e28 100644
--- a/include/comphelper/string.hxx
+++ b/include/comphelper/string.hxx
@@ -384,6 +384,19 @@ COMPHELPER_DLLPUBLIC bool isdigitAsciiString(std::u16string_view rString);
*/
COMPHELPER_DLLPUBLIC OUString sanitizeStringSurrogates(const OUString& rString);
+/** Adjust an index in case it points into the middle of a surrogate pair.
+
+ @param string An OUString
+
+ @param index A valid index into the string or to its end (i.e., must be in the range from zero
+ to the length of string, inclusive)
+
+ @return index - 1 if the original index pointed into the middle of a surrogate pair; otherwise
+ the unchanged index
+ */
+COMPHELPER_DLLPUBLIC sal_Int32 adjustIndexToStartOfSurrogate(
+ OUString const & string, sal_Int32 index);
+
} // namespace comphelper::string
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */