-
-
Notifications
You must be signed in to change notification settings - Fork 219
Closed
Description
For example:
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
SEXP embeddedNul() {
std::string hasNullByte("abc\0abc", 7);
String converted(hasNullByte);
return wrap(converted);
}
/*** R
embeddedNul()
*/
Sourcing this gives me:
> embeddedNul()
[1] "abc"
I would hope for either:
- An error, since we shouldn't silently lose data following the NUL byte; or
- A conversion to e.g. a raw character vector, preserving the embedded NUL.
It's worth stating that attempting to do this on the R side would give an error, e.g.
data <- as.raw(c(97, 98, 99, 0, 97, 98, 99))
rawToChar(data)
giving
> data <- as.raw(c(97, 98, 99, 0, 97, 98, 99))
> data
[1] 61 62 63 00 61 62 63
> rawToChar(data)
Error in rawToChar(data) : embedded nul in string: 'abc\0abc'
Metadata
Metadata
Assignees
Labels
No labels