Skip to content

[Rcpp-devel] Translate during coercion from String to Symbol?

2 messages · Kirill Müller, Dirk Eddelbuettel

#
Hi


It seems that R silently assumes that symbols are encoded in the native 
encoding. However, no attempt to reencode is made in Rf_installChar(), 
which is called by Symbol::Symbol(SEXP) in the CHARSXP case. I wonder if 
Rcpp should be calling Rf_install(Rf_translateChar(x)) instead, to 
ensure proper encoding.

Unfortunately, the better and faster Rf_installTrChar() isn't (yet) part 
of the API.


Best regards

Kirill
#
On 19 February 2017 at 00:02, Kirill M?ller wrote:
| It seems that R silently assumes that symbols are encoded in the native 
| encoding. However, no attempt to reencode is made in Rf_installChar(), 
| which is called by Symbol::Symbol(SEXP) in the CHARSXP case. I wonder if 
| Rcpp should be calling Rf_install(Rf_translateChar(x)) instead, to 
| ensure proper encoding.

That's entirely possible.

As you seem to know what code parts you looked at, would you mind sharing
that information so that we know better exactly _what_ you are talking about?
 
| Unfortunately, the better and faster Rf_installTrChar() isn't (yet) part 
| of the API.

Worst case we mock, copy or reimplement it.  Ultimately there may well be
changes coming down the road because of the Leeper + Cotton i18n project.

Dirk