Search code examples
rwindowsutf-8windows-10rstudio

I've set the system locale on Windows 10 to use the beta UTF-8 support, but RStudio does not recognize it


As you can see, I've changed the locale to support UTF-8

I've changed the locale to support UTF-8

However, when I try to change the locale in RStudio to UTF-8, I get an error:

> Sys.setlocale("LC_ALL", "en_US.utf8")
[1] ""
Warning message:
In Sys.setlocale("LC_ALL", "en_US.utf8") :
  OS reports request to set locale to "en_US.utf8" cannot be honored

I thought that since I enabled UTF-8 support for Windows, that I'd be able to change the locale in RStudio. Is there any way to do it?

Current locale is English_United States.1252:

> Sys.getlocale()
[1] "LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252"

Using RStudio build 351, with R version 4.1.0 on Windows 10 Home version 21H1


Solution

  • As it turns out, the problem was in how I was reading the data. Reading it with read.csv() read it with the encoding set by the locale. Changing it to readr::read_csv() made sure the file was being read with its own encoding, UTF-8.