Skip to content

Commit

Permalink
Remove dependency on LEVELS()
Browse files Browse the repository at this point in the history
Closes #1726
  • Loading branch information
lionel- committed Jul 2, 2024
1 parent 6f102ce commit a4bbdf2
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/internal/encoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,10 @@ bool str_needs_encoding(r_obj* x) {
return (!str_is_ascii_or_utf8(x)) && (x != NA_STRING);
}

#if (R_VERSION < R_Version(4, 5, 0))

#define MASK_ASCII 8
#define MASK_UTF8 64

// The first 128 values are ASCII, and are the same regardless of the encoding.
// Otherwise we enforce UTF-8.
static inline
Expand All @@ -200,5 +201,11 @@ bool str_is_ascii_or_utf8(r_obj* x) {
return (levels & MASK_ASCII) || (levels & MASK_UTF8);
}

#undef MASK_ASCII
#undef MASK_UTF8
#else

static inline
bool str_is_ascii_or_utf8(r_obj* x) {
return Rf_charIsUTF8(x);
}

#endif

0 comments on commit a4bbdf2

Please sign in to comment.