When using the R functions to manipulate files in Windows, e.g. dir()
, those with non-English characters, like Cyrillic, are presented as a sequence of "?".
Similarly, when using file.rename()
, if the new name contains non-English characters, the file is renamed with unreadable characters, apparently mapping to a different encoding.
There are a number of functions dealing with encoding for the file contents, but how can we deal with file names?
To reproduce the problem:
Outside R create the file "привет.txt" in the working dir; then in R:
dir()
# [1] "??????.txt"
# ...
Note that setting:
Sys.setlocale(category = "LC_ALL", locale="Russian")
doesn't help.
Note: I am using R 3.1.2 for Windows, under Windows 8.1 in English and in Windows consoles (cmd.exe
) I see the Cyrillic names properly.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…