MCPcopy Create free account
hub / github.com/RcppCore/Rcpp / set_encoding

Method set_encoding

inst/include/Rcpp/String.h:582–596  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

580 }
581
582 inline void set_encoding(cetype_t encoding) {
583 enc = encoding;
584
585 if (valid) {
586 // TODO: may longjmp on failure to translate?
587 const char* translated = Rf_translateCharUTF8(data);
588 data = Rf_mkCharCE(translated, encoding);
589 Rcpp_PreciousRelease(token);
590 token = Rcpp_PreciousPreserve(data);
591 } else {
592 data = get_sexp_impl();
593 token = Rcpp_PreciousPreserve(data);
594 valid = true;
595 }
596 }
597
598 bool operator<(const Rcpp::String& other) const {
599 return strcmp(get_cstring(), other.get_cstring()) < 0;

Callers 3

test_String_set_encodingFunction · 0.80

Calls 2

Rcpp_PreciousReleaseFunction · 0.85
Rcpp_PreciousPreserveFunction · 0.85

Tested by 3

test_String_set_encodingFunction · 0.64