Commit d88ff16 1 parent 7e1dc48 commit d88ff16 Copy full SHA for d88ff16
File tree 2 files changed +15
-1
lines changed
2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 6
6
#include < Rinternals.h>
7
7
#include < R_ext/Rdynload.h>
8
8
9
+ #define UTF8_MASK (1 <<3 )
10
+ #define ASCII_MASK (1 <<6 )
11
+
12
+ #define IS_ASCII (x ) (LEVELS(x) & ASCII_MASK)
13
+ #define IS_UTF8 (x ) (LEVELS(x) & UTF8_MASK)
14
+
9
15
namespace dplyr {
10
16
11
17
struct envs {
Original file line number Diff line number Diff line change 1
1
#include " dplyr.h"
2
2
3
+ SEXP as_utf8 (SEXP s) {
4
+ if (!IS_UTF8 (s) && !IS_ASCII (s)) {
5
+ s = Rf_mkCharCE (Rf_translateCharUTF8 (s), CE_UTF8);
6
+ }
7
+ return s;
8
+ }
9
+
3
10
R_xlen_t find_first (SEXP haystack, SEXP needle) {
11
+ needle = as_utf8 (needle);
4
12
R_xlen_t n = XLENGTH (haystack);
5
13
R_xlen_t i_name = 0 ;
6
14
for (; i_name < n; i_name++) {
7
- if (needle == STRING_ELT (haystack, i_name)) break ;
15
+ if (needle == as_utf8 ( STRING_ELT (haystack, i_name) )) break ;
8
16
}
9
17
10
18
return i_name;
You can’t perform that action at this time.
0 commit comments