You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/07/06 11:50:06 UTC

[GitHub] [arrow] SG011 commented on a diff in pull request #13497: ARROW-16970: [C++][Gandiva] ENCODE(UTF-8 -> UTF-16BE and UTF-8 -> UTF-16LE) and DECODE(UTF-16BE -> UTF-8 and UTF-16LE -> UTF-8)

SG011 commented on code in PR #13497:
URL: https://github.com/apache/arrow/pull/13497#discussion_r914745655


##########
cpp/src/gandiva/gdv_string_function_stubs.cc:
##########
@@ -264,6 +264,298 @@ const char* gdv_fn_lower_utf8(int64_t context, const char* data, int32_t data_le
   return out;
 }
 
+// converts utf8 to utf16 encoding
+GANDIVA_EXPORT
+const char* gdv_fn_encode(int64_t context, const char* data, int32_t data_len,
+                          const char* charset, int32_t charset_len, int32_t* out_len) {
+  if (data_len == 0) {
+    *out_len = 0;
+    return "";
+  }
+
+  char* out =
+      reinterpret_cast<char*>(gdv_fn_context_arena_malloc(context, 32 * data_len));
+  if (out == nullptr) {
+    gdv_fn_context_set_error_msg(context, "Could not allocate memory for output string");
+    *out_len = 0;
+    return "";
+  }
+
+  int32_t char_len;
+  uint32_t char_codepoint;
+
+  if (memcmp(charset, "UTF-16BE", 8) == 0 || memcmp(charset, "utf-16be", 8) == 0) {

Review Comment:
   Projector tests and gdv_function_stubs_test.cc also needs to be changed accordingly? 



-- 
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.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org