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



##########
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:
       This is thin for now, but this might evolve into perhaps something like 
`cpp11::utf8_strings` class that would eagerly convert at construction time. 




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