special characters øæå in Rstudio projects

Hello,
If I have a script with æåø characters (danish) and then create a project they get replaced with ? etc. Then I have to go over the file and correct everything and it is then fine. If Ithen open the script without the project the characters get messed op again.. Is there a solution to this problem?

Thanks

1 Like

Character encoding sits somehow in between R and your OS; it can be difficult to troubleshoot. (i.e. welcome to encoding hell! :slight_smile:)

What platform are you using? And what locale you have set up (= what do you get when running Sys.getlocale() ?)

When I had a similar issue – I had trouble displaying Czech, not Danish characters, so not exactly the same but very similar – I solved it by including this code in my .Rprofile

if (.Platform$OS.type == 'windows') {
  Sys.setlocale(category = 'LC_ALL','English_United States.1250')
} else {
  Sys.setlocale(category = 'LC_ALL','en_US.UTF-8')
}

You may want to edit the script to suit your language - code page 1250 is relevant for Central European languages, I believe that Danish script uses 865 but I may be wrong here...

@jlacko: ¨
Hi. Thanks for reply.
Sys.getlocale() gives the following:
"LC_COLLATE=Danish_Denmark.1252;LC_CTYPE=Danish_Denmark.1252;LC_MONETARY=Danish_Denmark.1252;LC_NUMERIC=C;LC_TIME=Danish_Denmark.1252"

I have not tried to edit my .Rprofile yet...
My platform is Windows 10.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.