nealrichardson commented on a change in pull request #7819:
URL: https://github.com/apache/arrow/pull/7819#discussion_r473080054



##########
File path: r/src/arrow_cpp11.h
##########
@@ -35,8 +36,45 @@ SEXP as_sexp(const std::vector<std::shared_ptr<T>>& vec);
 //       https://github.com/apache/arrow/pull/7819#discussion_r471664878
 #include <cpp11.hpp>
 
+// borrowed from enc package
+// because R does not make these macros available (i.e. from Defn.h)
+#define UTF8_MASK (1 << 3)
+#define ASCII_MASK (1 << 6)
+
+#define IS_ASCII(x) (LEVELS(x) & ASCII_MASK)
+#define IS_UTF8(x) (LEVELS(x) & UTF8_MASK)
+
 namespace arrow {
 namespace r {
+
+// functions that need to be called from an unwind_protect()
+namespace unsafe {
+
+inline SEXP utf8_r_string(SEXP s) {
+  if (!IS_UTF8(s) && !IS_ASCII(s)) {

Review comment:
       Are you sure these utilities are necessary? `translateCharUTF8` also 
checks IS_UTF8 and IS_ASCII and exits early: 
https://github.com/wch/r-source/blob/122dcf452ec5eacdd66e165457985bded1af4fee/src/main/sysutils.c#L1085




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