On 24/05/2017 9:59 AM, Hiroyuki Kawakatsu wrote:
On 2017-05-24, Duncan Murdoch wrote:
[...]
Okay, how about if we weaken the test?
[...]
try
stopifnot(path.expand(paste0("~/", filename)) ==
paste0(path.expand("~/"), filename))
Nope:
## path.expand shouldn't translate to local encoding PR#17120
filename <- "\U9b3c.R"
#stopifnot(identical(path.expand(paste0("~/", filename)),
stopifnot(path.expand(paste0("~/", filename)) ==
+ paste0(path.expand("~/"), filename))
Error: path.expand(paste0("~/", filename)) == paste0(path.expand("~/"), ....
is not TRUE
Execution halted
Thanks. I've made that test conditional on running on Windows, and
re-opened bug 17120. I indicated that it's now a Unix-only bug.
This may be a first: a case where R handles non-native characters
better in Windows than it does in Unix. I'm sure this will show up in a
Microsoft ad soon :-).
Duncan Murdoch
The problem is that path.expand(), or do_pathexpand() for
non-windoze calls translateChar() which in turn calls
translateToNative() which is unknown to make check (but not to R
--vanilla) under my setup. Once it is unknown, there seems to be no
way to force an encoding:
## path.expand shouldn't translate to local encoding PR#17120
filename <- "\U9b3c.R"
print(Encoding(filename))
[1] "UTF-8"
y1 <- paste0("~/", filename)
print(Encoding(y1))
[1] "UTF-8"
y2 <- path.expand(y1)
print(Encoding(y2))
[1] "unknown"
y3a <- iconv(y2, to="UTF-8")
print(Encoding(y3a))
[1] "unknown"
y3b <- enc2utf8(y2)
print(Encoding(y3b))
[1] "unknown"
Encoding(y2) <- "UTF-8"
print(Encoding(y2))
[1] "unknown"
h.
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel