Issues with French text showing up incorrectly in R script in RStudio

You're right, a reprex isn't necessary to illuminate the problem.

This came up recenty with Greek, which traced back to a RStudio 1.1.x installation. Since your colleague is on 1.2.5xxx, that's not likely to be the problem here.

Here's how we want it working, cut and pasted from R Studio

text <- "Mes pensées accompagnent les victimes de l'attaque de Romans-sur-Isère, les blessés, leurs familles. Toute la lumière sera faite sur cet acte odieux qui vient endeuiller notre pays déjà durement éprouvé ces dernières semaines."

text
#> [1] "Mes pensées accompagnent les victimes de l'attaque de Romans-sur-Isère, les blessés, leurs familles. Toute la lumière sera faite sur cet acte odieux qui vient endeuiller notre pays déjà durement éprouvé ces dernières semaines."

Created on 2020-04-04 by the reprex package (v0.3.0)

with

sessionInfo() 
#> R version 3.6.3 (2020-02-29)
#> Platform: x86_64-apple-darwin15.6.0 (64-bit)
#> Running under: macOS Catalina 10.15.3
#> 
#> Matrix products: default
#> BLAS:   /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib
#> LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib
#> 
#> locale:
#> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> loaded via a namespace (and not attached):
#>  [1] compiler_3.6.3  magrittr_1.5    tools_3.6.3     htmltools_0.4.0
#>  [5] yaml_2.2.1      Rcpp_1.0.4      stringi_1.4.6   rmarkdown_2.1  
#>  [9] highr_0.8       knitr_1.28      stringr_1.4.0   xfun_0.12      
#> [13] digest_0.6.25   rlang_0.4.5     evaluate_0.14

Created on 2020-04-04 by the reprex package (v0.3.0)

Anything Windows can do macOS can do better, and anything that macOS can do Linus can do better still. But if Windows were the problem, it would surface there more often. But I haven't seen that much.

So, it's an encoding issue, then, as you thought. Looking at Sys.getlocale() my sense is that the differences between en_CA.UTF-8 end**US**.UTF-8 shouldn't matter.

If the encoding of the source document renders correctly (source meaning the last file through which the text passed) in other apps than RStudio, then it's either a version-specific RStudio version bug (again, unlikely) or a configuration issue within RStudio's project or global preferences.

In Code | Saving there is an encoding option. Mine is set to UTF-8. If your colleague's is also, and I'm right that 1.2.5x makes no never mind, and the source file renders correctly, I'm at an official plumb out of suggestions resting place.

Let us know back and mark your result as a solution if success?

2 Likes