Instead of opening Rstudio or similar to run my R scripts I have gotten into the habit of running scripts with Rscript.exe
from the command line. Works great except when the file I feed Rscript.exe has non-ASCII characters. If my Rscript subsequently calls other Rscripts there are no issues. Concrete example:
I have two files
# test.R
print(intToUtf8(230))
print("æ")
# run_test.R
source("test.R", encoding = "UTF-8")
Now if I go to the command line and run: [...] \R\R-4.0.2\bin\Rscript.exe test.R
I get:
[1] "æ"
[1] "æ"
My current solution (which I want to get around): [...] \R\R-4.0.2\bin\Rscript.exe run_test.R
[1] "æ"
[1] "æ"
Possibly relevant info:
I would like to continue saving my script files with "UTF-8".
R version 4.0.2
Tried running scripts from Powershell, Command Prompt, Git Bash. Always the same result.
Locale:
Sys.getlocale()
# "LC_COLLATE=Icelandic_Iceland.1252;LC_CTYPE=Icelandic_Iceland.1252;LC_MONETARY=Icelandic_Iceland.1252;LC_NUMERIC=C;LC_TIME=Icelandic_Iceland.1252"