Skip to content

Commit 6621930

Browse files
author
thirdwing
committed
set_encoding fixed
1 parent 6b231e5 commit 6621930

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

inst/include/Rcpp/String.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -354,12 +354,11 @@ namespace Rcpp {
354354
return std::wstring( s, s + strlen(s) );
355355
}
356356

357-
358357
inline const char* get_cstring() const {
359358
return buffer_ready ? buffer.c_str() : CHAR(data) ;
360359
}
361360

362-
inline const char* get_encoding() const {
361+
inline const std::string get_encoding() const {
363362
switch (enc) {
364363
case CE_BYTES:
365364
return "bytes";
@@ -373,14 +372,12 @@ namespace Rcpp {
373372
}
374373

375374
inline void set_encoding( cetype_t encoding ) {
376-
if (enc != encoding) {
377-
enc = encoding;
378-
if (data != NULL)
379-
data = Rf_mkCharCE(Rf_translateCharUTF8(data), enc);
380-
}
375+
enc = encoding;
376+
if (data != NULL)
377+
data = Rf_mkCharCE(Rf_translateCharUTF8(data), enc);
381378
}
382379

383-
inline void set_encoding(const char* encoding) {
380+
inline void set_encoding(const std::string & encoding) {
384381
if ( encoding == "bytes" ) {
385382
enc = CE_BYTES;
386383
} else if ( encoding == "latin1" ) {

0 commit comments

Comments
 (0)