Bug 16784 - file.path(unknownEncoding, UTF-8Encoding) -> unknownEncoding, unlike paste(). Causes file routines to fail.
Summary: file.path(unknownEncoding, UTF-8Encoding) -> unknownEncoding, unlike paste()....
Alias: None
Product: R
Classification: Unclassified
Component: I/O (show other bugs)
Version: R 3.2.3
Hardware: x86_64/x64/amd64 (64-bit) Windows 64-bit
: P5 normal
Assignee: R-core
Depends on:
Reported: 2016-03-25 21:17 UTC by Bill Dunlap
Modified: 2016-03-25 21:17 UTC (History)
0 users

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Bill Dunlap 2016-03-25 21:17:40 UTC
With the Windows GUI and R-3.2.3 file.path(x,y) does not act like paste(x,y,sep=.Platform$file.sep) when the Encodings of x and y differ.
file.path() makes a string that dir.create() cannot deal with, but paste's
output is fine.  E.g.,

> f <- "\U043F\U0430\U043F\U043A\U0430" # Cyrillic "papka"
> tfile <- tempfile()
> dir.create( tFolder1 <- file.path(tfile, f), recursive = TRUE ) # error
Warning message:
In dir.create(tFolder1 <- file.path(tfile, f), recursive = TRUE) :
  cannot create dir 'C:\Users\wdunlap\AppData\Local\Temp\RtmpGETY7v\file2ed850c48d8\<U+043F><U+0430><U+043F><U+043A><U+0430>', reason 'Invalid argument'
> dir.create( tFolder2 <- paste(tfile, f, sep=.Platform$file.sep), recursive = TRUE )
> Encoding(tFolder1) # unknown
[1] "unknown"
> Encoding(tFolder2) # UTF-8
[1] "UTF-8"
> sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base