This is an automated email from the ASF dual-hosted git repository.

jianliangqi pushed a commit to branch clucene
in repository https://gitbox.apache.org/repos/asf/doris-thirdparty.git


The following commit(s) were added to refs/heads/clucene by this push:
     new da906ebf [Feature] add string to wstring function (#101)
da906ebf is described below

commit da906ebf3cd12b6ac21f67e9d505425962df82f2
Author: zzzxl <33418555+zzzxl1...@users.noreply.github.com>
AuthorDate: Thu Jul 13 10:24:35 2023 +0800

    [Feature] add string to wstring function (#101)
---
 src/shared/CLucene/config/repl_wchar.h |  1 +
 src/shared/CLucene/config/utf8.cpp     | 14 ++++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/src/shared/CLucene/config/repl_wchar.h 
b/src/shared/CLucene/config/repl_wchar.h
index 756f1b86..8fd598db 100644
--- a/src/shared/CLucene/config/repl_wchar.h
+++ b/src/shared/CLucene/config/repl_wchar.h
@@ -30,6 +30,7 @@ CLUCENE_SHARED_EXPORT size_t lucene_wcsntoutf8 (char *,  
const wchar_t *, size_t
 #define lucene_wcstoutf8string(str,strlen) str
 #else
 CLUCENE_SHARED_EXPORT std::string lucene_wcstoutf8string(const wchar_t* str, 
size_t strlen);
+CLUCENE_SHARED_EXPORT std::wstring lucene_utf8stows(const std::string& s);
 #endif
 CLUCENE_SHARED_EXPORT size_t lucene_utf8charlen(const unsigned char p); //< 
the number of characters that this first utf8 character will expect
 
diff --git a/src/shared/CLucene/config/utf8.cpp 
b/src/shared/CLucene/config/utf8.cpp
index 471a1a26..d921a0cc 100644
--- a/src/shared/CLucene/config/utf8.cpp
+++ b/src/shared/CLucene/config/utf8.cpp
@@ -258,4 +258,18 @@ std::string lucene_wcstoutf8string(const wchar_t* str, 
size_t strlen){
 
   return result;
 }
+
+std::wstring lucene_utf8stows(const std::string& s) {
+  std::wstring ws;
+  size_t size = 0;
+  for (size_t i = 0; i < s.size();) {
+    size_t n = lucene_utf8charlen(s[i]);
+    size++;
+    i += n;
+  }
+  ws.resize(size);
+  lucene_utf8towcs(ws.data(), s.data(), s.length());
+  return ws;
+}
+
 #endif


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to