Is there possible to manipulate individual characters with Rcpp::string object? I need to do some string substitutions while keeping encodings, so I think Rcpp::string might help.
What I want to achieve is something like:
// [[Rcpp::export]]
Rcpp::string demo1(const Rcpp::String txt) {
std::string s = txt.get_cstring(); // this would lose character encoding.
int nlen = s.size();
char out[nlen];
for (int i=0; i<nlen; i++) {
// if match condition then
out[i] = s[i];
}
return out;
}