diff --git a/src/bmerge.c b/src/bmerge.c index 6cf970ca27..4197c5f8dc 100644 --- a/src/bmerge.c +++ b/src/bmerge.c @@ -17,9 +17,6 @@ Differences over standard binary search (e.g. bsearch in stdlib.h) : o non equi joins (no != yet) since 1.9.8 */ -#define ENC_KNOWN(x) (LEVELS(x) & 12) -// 12 = LATIN1_MASK (1<<2) | UTF8_MASK (1<<3) // Would use these definitions from Defn.h, but that appears to be private to R. Hence 12. - #define EQ 1 #define LE 2 #define LT 3 diff --git a/src/data.table.h b/src/data.table.h index b36a1f1fad..ab52a1757f 100644 --- a/src/data.table.h +++ b/src/data.table.h @@ -33,9 +33,14 @@ // #include // the debugging machinery + breakpoint aidee // raise(SIGINT); -#define IS_UTF8(x) (LEVELS(x) & 8) -#define IS_ASCII(x) (LEVELS(x) & 64) -#define IS_LATIN(x) (LEVELS(x) & 4) +/* we mean the encoding bits, not CE_NATIVE in a UTF-8 locale */ +#define IS_UTF8(x) (getCharCE(x) == CE_UTF8) +#define IS_LATIN(x) (getCharCE(x) == CE_LATIN1) +#if R_VERSION < R_Version(4, 5, 0) +# define IS_ASCII(x) (LEVELS(x) & 64) +#else +# define IS_ASCII(x) (Rf_charIsASCII(x)) // no CE_ASCII +#endif #define IS_TRUE(x) (TYPEOF(x)==LGLSXP && LENGTH(x)==1 && LOGICAL(x)[0]==TRUE) #define IS_FALSE(x) (TYPEOF(x)==LGLSXP && LENGTH(x)==1 && LOGICAL(x)[0]==FALSE) #define IS_TRUE_OR_FALSE(x) (TYPEOF(x)==LGLSXP && LENGTH(x)==1 && LOGICAL(x)[0]!=NA_LOGICAL)