Skip to content
Prev 58716 / 63424 Next

Possible Bug: file.exists() Function. Due to UTF-8 Encoding differences on Windows between R 4.0.1 and R 3.6.3?

Hi Tomas,

I received a report about R 4.0.0 in the knitr package
(https://github.com/yihui/knitr/issues/1840), and I think it is
related to the issue here. I created a minimal reproducible example
below:

owd = setwd(tempdir())
z = 'K\u00e4sch.txt'
file.create(z)
list.files()
file.exists(list.files())
setwd(owd)

Output:
[1] TRUE
[1] "K?sch.txt"
[1] FALSE
I wonder if it is expected that file.exists() returns FALSE here.
R version 4.0.1 (2020-06-06)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
system code page: 936

FWIW, I also tested Chinese characters in the variable `z` above, and
file.exists() returns TRUE only after I Sys.setlocale(, "Chinese").

Regards,
Yihui
On Thu, Jun 11, 2020 at 3:11 AM Tomas Kalibera <tomas.kalibera at gmail.com> wrote:

Thread (13 messages)

Juan Telleria Ruiz de Aguirre Possible Bug: file.exists() Function. Due to UTF-8 Encoding differences on Windows between R 4.0.1 and R 3.6.3? Jun 10 Tomas Kalibera Possible Bug: file.exists() Function. Due to UTF-8 Encoding differences on Windows between R 4.0.1 and R 3.6.3? Jun 10 Dirk Eddelbuettel Possible Bug: file.exists() Function. Due to UTF-8 Encoding differences on Windows between R 4.0.1 and R 3.6.3? Jun 10 Kevin Ushey Possible Bug: file.exists() Function. Due to UTF-8 Encoding differences on Windows between R 4.0.1 and R 3.6.3? Jun 10 Juan Telleria Ruiz de Aguirre Possible Bug: file.exists() Function. Due to UTF-8 Encoding differences on Windows between R 4.0.1 and R 3.6.3? Jun 10 Yihui Xie Possible Bug: file.exists() Function. Due to UTF-8 Encoding differences on Windows between R 4.0.1 and R 3.6.3? Jun 21 Tomas Kalibera Possible Bug: file.exists() Function. Due to UTF-8 Encoding differences on Windows between R 4.0.1 and R 3.6.3? Jun 22 Yihui Xie Possible Bug: file.exists() Function. Due to UTF-8 Encoding differences on Windows between R 4.0.1 and R 3.6.3? Jun 23 Johannes Rauh `basename` and `dirname` change the encoding to "UTF-8" Jun 29 Duncan Murdoch `basename` and `dirname` change the encoding to "UTF-8" Jun 29 Kevin Ushey `basename` and `dirname` change the encoding to "UTF-8" Jun 29 Tomas Kalibera `basename` and `dirname` change the encoding to "UTF-8" Jun 30 Johannes Rauh `basename` and `dirname` change the encoding to "UTF-8" Jun 30