Repository navigation
Description
System details
RStudio Edition : 2024.04.2 Build 764
RStudio Version : RStudio 2024.04.2+764 "Chocolate Cosmos" Release (e4392fc9ddc21961fd1d0efd47484b43f07a4177, 2024-06-05) for windows
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) RStudio/2024.04.2+764 Chrome/120.0.6099.291 Electron/28.3.1 Safari/537.36, Quarto 1.4.555
OS Version : Windows 10 Enterprise
R Version : 4.4.1
Steps to reproduce the problem
`
Sys.getlocale()
[1] "C" # a useless locale
txt <- "æøå" # this fails now
txt
[1] "���"
Sys.setlocale(category = "LC_ALL", locale = "") # setting the proper locale
[1] "LC_COLLATE=Norwegian Bokmål_Norway.utf8;LC_CTYPE=Norwegian Bokmål_Norway.utf8;LC_MONETARY=Norwegian Bokmål_Norway.utf8;LC_NUMERIC=C;LC_TIME=Norwegian Bokmål_Norway.utf8"
Sys.getlocale()
[1] "LC_COLLATE=Norwegian Bokmål_Norway.utf8;LC_CTYPE=Norwegian Bokmål_Norway.utf8;LC_MONETARY=Norwegian Bokmål_Norway.utf8;LC_NUMERIC=C;LC_TIME=Norwegian Bokmål_Norway.utf8"
txt <- "æøå" # and now this works fine
txt
[1] "æøå"
View(mpg) # calls the Viewer in RStudio
Sys.getlocale()
[1] "C" # and we are back to the same useless locale again
txt <- "æøå"
txt
[1] "���"`
Describe the problem in detail
I am using a computer with norwegian locale, but RStudio does not seem to register this in the first place. When I run in the Console:
`
Sys.getlocale()
[1] "C"`
If I start R outside RStudio it looks like this:
`
Sys.getlocale()
[1] "LC_COLLATE=Norwegian Bokmål_Norway.utf8;LC_CTYPE=Norwegian Bokmål_Norway.utf8;LC_MONETARY=Norwegian Bokmål_Norway.utf8;LC_NUMERIC=C;LC_TIME=Norwegian Bokmål_Norway.utf8"`
This is correct, and letters like æøå are recognized. Next, I set the locale in RStudio:
`
Sys.setlocale(category = "LC_ALL", locale = "")
[1] "LC_COLLATE=Norwegian Bokmål_Norway.utf8;LC_CTYPE=Norwegian Bokmål_Norway.utf8;LC_MONETARY=Norwegian Bokmål_Norway.utf8;LC_NUMERIC=C;LC_TIME=Norwegian Bokmål_Norway.utf8"
Sys.getlocale()
[1] "LC_COLLATE=Norwegian Bokmål_Norway.utf8;LC_CTYPE=Norwegian Bokmål_Norway.utf8;LC_MONETARY=Norwegian Bokmål_Norway.utf8;LC_NUMERIC=C;LC_TIME=Norwegian Bokmål_Norway.utf8"`
Everything seems to work fine, but as soon as I make a call to View() (opens a data.frame for viewing) it is set back to the old and useless locale again!
`
View(mpg)
Sys.getlocale()
[1] "C"`
Also, adding the Sys.setlocale-statement to my .Rprofile has no effect at all, it is clearly being reset again after the execution of .Rprofile
Describe the behavior you expected
First, I expect RStudio to use the locale of my computer in the first place. This is clearly done in R outside RStudio.
Second, I would expect setting the locale in my .Rprofile would take effect and not be reset by RStudio.
Third, when I set the locale explicitly in a session, I do not expect it to change back to some useless locale each time I call View()
- [x ] I have read the guide for submitting good bug reports.
- [ x] I have installed the latest version of RStudio, and confirmed that the issue still persists.
- If I am reporting an RStudio crash, I have included a diagnostics report.
- [ x] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
Activity
ronblum commentedon Jul 26, 2024
@larssnip Thank you for raising the issue: I can confirm that
kevinushey commentedon Jul 30, 2024
For what it's worth, I was not able to reproduce with this code:
so reproducing seems to require explicitly changing the system language to Norwegian?
ronblum commentedon Jul 30, 2024
@kevinushey Yes, that's what I had to do.
larssnip commentedon Aug 6, 2024
Yes, my computer uses a norwegian Windows, and I guess this code:
Sys.setlocale(category = "LC_ALL", locale = "")will fetch the locale from windows and use this in R/RStudio. This works but, as explained above, only a short time before RStudio resets it. However, I have found that if I instead use:
Sys.setlocale(category = "LC_ALL", locale = "NO_NB.utf8")it works and persists! This means I do not collect the locale from Windows, but specify it like this. This is NOT the same locale that I get from windows, but it works nice with the nordic letters. And it seems to persist, i.e. is not reset by RStudio. I now put this into my .Rprofile and the problems seems to be solved.
ronblum commentedon Aug 6, 2024
@larssnip That's great--I'm glad to hear that there's a workaround!
It appears to be an issue with the special character in the name. I tried several other languages, including Norwegian (Nynorsk) and Arabic (Egypt), which work. However, French (Côte d’Ivoire) has the same bug as Norwegian (Bokmål).
Side note: Almost all of the names have been anglicized, without special characters--for example, French not français--so I'm surprised to see a few that haven't been--e.g., Côte d’Ivoire not Ivory Coast.
jthomasmock commentedon Sep 27, 2024
Glad to hear about the workaround and details, we'll evaluate this alongside other locale and i18n issues in the future.
oyvindbso commentedon Nov 19, 2025
I finally found out what was the problem (the å in Bokmål) and found this post. This has bugged me for a looong time.
It would be great if Rstudio could support it (even if Bokmål is a very minor language internationally). I was not able to reproduce the error in R gui so it is only a problem in Rstudio.
My code has looked like this since it became a problem;
some r codeSys.setlocale(category = "LC_ALL", locale = "")some r codeSys.setlocale(category = "LC_ALL", locale = "")some r codeOf course if I had used the other version of Norwegian in the system settings (Nynorsk) there wouldn't have been a problem.
repair the windows locale when it is changed behind r's back (#18657)