imay commented on a change in pull request #3345: [FIX] fix doris string 
functions not support multibyte string
URL: https://github.com/apache/incubator-doris/pull/3345#discussion_r410147852
 
 

 ##########
 File path: be/src/exprs/string_functions.cpp
 ##########
 @@ -266,7 +332,25 @@ StringVal StringFunctions::reverse(FunctionContext* 
context, const StringVal& st
     if (UNLIKELY(result.is_null)) {
         return result;
     }
-    std::reverse_copy(str.ptr, str.ptr + str.len, result.ptr);
+
+    for (size_t i = 0, char_size = 0; i < str.len; i += char_size) {
+        unsigned char byte = (unsigned)(str.ptr)[i];
+        if (byte >= 0xFC) {
+            char_size = 6;
+        } else if (byte >= 0xF8) {
+            char_size = 5;
+        } else if (byte >= 0xF0) {
+            char_size = 4;
+        } else if (byte >= 0xE0) {
+            char_size = 3;
+        } else if (byte >= 0xC0) {
+            char_size = 2;
+        } else {
+            char_size = 1;
+        }
 
 Review comment:
   Can you write a function and to reuse it?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to