RStudio encoding UTC-8 scandinavian letters

I recently installed the newest version of RStudio.
In the new version it is not possible to run rmarkdown or quarto scripts with scandinavian letters like æ,ø and å. I have tried to use File > Reopen with encoding and also change the encoding in the RProject that contains the files.

Example:
d1 <- d %>%

  • group_by(ansattnr, avdeling) %>%
  • summarise(år_2019 = sum(år_2019, na.rm=TRUE),
  •         år_2020 = sum(år_2020, na.rm=TRUE),
    
  •         år_2021 = sum(år_2021, na.rm=TRUE)) %>%
    
  • mutate(avdeling_kort = case_when(str_sub(avdeling,1,3) == "Akv" ~ "Akvakultur",
  •                                str_sub(avdeling,1,3) == "Mar" ~ "Marine",
    
  •                                str_sub(avdeling,1,3) == "Sjø" ~ "Sjømat")) %>%
    

Error: unexpected symbol in:
" str_sub(avdeling,1,3) == "Mar" ~ "Marine",
str_sub(avdeling,1,3) == "Sj�" ~ "Sj�mat""

Version information:
RStudio 2022.02.2+485 "Prairie Trillium" Release (8acbd38b0d4ca3c86c570cf4112a8180c48cc6fb, 2022-04-19) for Windows
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/5.12.8 Chrome/69.0.3497.128 Safari/537.36

1 Like

I have similar issue.
It seems R starts using wrong locale when started from RStudio.

The command Sys.getlocale() return "c" in RStudio , while the same command in Rgui or Rterm ("native R") gives a long list of UTF8 references. I do not know how to solve this. And this happens only in one out of my two computers. I do not know what is the underlying problem or how to slove it.
Rstudio 2022.02.2 build 485, R4.2.0, Windows 10