summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2023-04-22 10:28:20 +0200
committerMike Kaganski <mike.kaganski@collabora.com>2023-04-22 12:46:01 +0200
commit0f6ec3939df6b0e3263fc07a2067bbbfc6421ac7 (patch)
tree42d99d08f48fd06da9c0ee89bb6e4ab264ba03bf
parentab55c7bffddc1a4c8f3d971d24bae297a15f3346 (diff)
Introduce o3tl::toU converting wstring_view to u16string_view
Change-Id: I5be9aa767020c2516984e47fcd0f51d4661fdf17 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150779 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r--include/o3tl/char16_t2wchar_t.hxx4
-rw-r--r--lingucomponent/source/numbertext/numbertext.cxx2
2 files changed, 5 insertions, 1 deletions
diff --git a/include/o3tl/char16_t2wchar_t.hxx b/include/o3tl/char16_t2wchar_t.hxx
index cf0415343147..fcbbaf079ce3 100644
--- a/include/o3tl/char16_t2wchar_t.hxx
+++ b/include/o3tl/char16_t2wchar_t.hxx
@@ -11,6 +11,8 @@
#include <sal/config.h>
+#include <string_view>
+
namespace o3tl
{
#if defined _WIN32
@@ -37,6 +39,8 @@ inline wchar_t* toW(char16_t* p) { return reinterpret_cast<wchar_t*>(p); }
inline wchar_t const* toW(char16_t const* p) { return reinterpret_cast<wchar_t const*>(p); }
inline char16_t* toU(wchar_t* p) { return reinterpret_cast<char16_t*>(p); }
inline char16_t const* toU(wchar_t const* p) { return reinterpret_cast<char16_t const*>(p); }
+
+inline std::u16string_view toU(std::wstring_view v) { return { toU(v.data()), v.size() }; }
#endif
}
diff --git a/lingucomponent/source/numbertext/numbertext.cxx b/lingucomponent/source/numbertext/numbertext.cxx
index 4f868adb74d8..aec03e1f5e8e 100644
--- a/lingucomponent/source/numbertext/numbertext.cxx
+++ b/lingucomponent/source/numbertext/numbertext.cxx
@@ -128,7 +128,7 @@ OUString SAL_CALL NumberText_Impl::getNumberText(const OUString& rText, const Lo
bool result = m_aNumberText.numbertext(sResult, aLangCode.getStr());
DBG_ASSERT(result, "numbertext: false");
#if defined(_WIN32)
- OUString aResult(o3tl::toU(sResult.c_str()));
+ OUString aResult(o3tl::toU(sResult));
#else
OUString aResult = OUString::fromUtf8(Numbertext::wstring2string(sResult));
#endif