Skip to content

Commit 8ef43af

Browse files
committed
Remove dependency on LEVELS()
Closes #1726
1 parent 23f0f30 commit 8ef43af

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/internal/encoding.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,10 @@ bool str_needs_encoding(r_obj* x) {
189189
return (!str_is_ascii_or_utf8(x)) && (x != NA_STRING);
190190
}
191191

192+
#if (R_VERSION < R_Version(4, 5, 0))
193+
192194
#define MASK_ASCII 8
193195
#define MASK_UTF8 64
194-
195196
// The first 128 values are ASCII, and are the same regardless of the encoding.
196197
// Otherwise we enforce UTF-8.
197198
static inline
@@ -200,5 +201,11 @@ bool str_is_ascii_or_utf8(r_obj* x) {
200201
return (levels & MASK_ASCII) || (levels & MASK_UTF8);
201202
}
202203

203-
#undef MASK_ASCII
204-
#undef MASK_UTF8
204+
#else
205+
206+
static inline
207+
bool str_is_ascii_or_utf8(r_obj* x) {
208+
return Rf_charIsUTF8(x);
209+
}
210+
211+
#endif

0 commit comments

Comments
 (0)