[Rd] translateChar in NewName in bind.c

Suharto Anggono Suharto Anggono suharto_anggono at yahoo.com
Sun Jul 30 16:57:53 CEST 2017


R devel's bind.c has been ported to R patched. Is it OK while names of 'unlist' or 'c' result may be not strictly the same as in R 3.4.1 because of changed function 'NewName' in bind.c?

Using 'translateCharUTF8' instead of 'translateChar' is as it should be. It has an effect in non-UTF-8 locale for this example.
x <- list(1:2)
names(x) <- "\ue7"
res <- unlist(x)
charToRaw(names(res)[1])

Directly assigning 'tag' to 'ans' is more efficient, but may be different from in R 3.4.1 that involves 'translateCharUTF8', that is also correct. It has an effect for this example.
x <- 0
names(x) <- "\xe7"
Encoding(names(x)) <- "latin1"
res <- c(x)
Encoding(names(res))
charToRaw(names(res))

--------------------------------------------
On Tue, 13/6/17, Tomas Kalibera <tomas.kalibera at gmail.com> wrote:

 Subject: Re: [Rd] translateChar in NewName in bind.c

@r-project.org
 Date: Tuesday, 13 June, 2017, 2:35 PM

 Thanks, fixed in R-devel.
 Best
 Tomas

 On
 06/11/2017 02:30 PM, Suharto Anggono Suharto Anggono via
 R-devel wrote:
 > I see another thing in
 function 'NewName' in bind.c. In
 > else if (*CHAR(tag)) ,
 > 'ans' is basically copied from
 'tag'. Could the whole thing there be just the
 following?
 > ans = tag;
 > It seems to me that it can also replace
 > ans = R_BlankString;
 >
 in 'else'; so,
 > else if
 (*CHAR(tag))
 > and
 >
 else
 > can be merged to be just
 > else .
 >
 >
 --------------------------------------------
 >
 >
 >   Subject: translateChar in NewName in
 bind.c
 >   To: r-devel at r-project.org
 >   Date: Saturday, 10 June, 2017, 9:14
 PM
 >   
 >   In
 function 'NewName' in bind.c (https://svn.r-project.org/R/trunk/src/main/bind.c),
 in
 >   else if (*CHAR(base)) ,
 >   'translateChar' is used. Should
 it be
 >   'translateCharUTF8'
 instead? The end result is marked as
 >  
 UTF-8:
 >   mkCharCE(cbuf, CE_UTF8)
 >   Other cases already use
 >   'translateCharUTF8'.
 >
 >
 ______________________________________________
 > R-devel at r-project.org
 mailing list
 > https://stat.ethz.ch/mailman/listinfo/r-devel



More information about the R-devel mailing list