sagnikc-dremio commented on a change in pull request #7402:
URL: https://github.com/apache/arrow/pull/7402#discussion_r444588872



##########
File path: cpp/src/gandiva/precompiled/string_ops.cc
##########
@@ -284,6 +284,49 @@ const char* reverse_utf8(gdv_int64 context, const char* 
data, gdv_int32 data_len
   return ret;
 }
 
+// Trim a utf8 sequence
+FORCE_INLINE
+const char* trim_utf8(gdv_int64 context, const char* data, gdv_int32 data_len,
+                      int32_t* out_len) {
+  if (data_len == 0) {
+    *out_len = 0;
+    return "";
+  }
+
+  gdv_int32 start = 0, end = data_len - 1;
+  // start and end denote the first and last positions of non-space
+  // characters in the input string respectively
+  while (start <= end && data[start] == ' ') {
+    ++start;
+  }
+  while (end >= start && data[end] == ' ') {

Review comment:
       Verified that for utf8, 0x20 is always a single-byte space and is not 
part of any multi-byte characters.




----------------------------------------------------------------
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:
[email protected]


Reply via email to