3

When I write Norwegian text in R Notebook and produce an HTML_NOTEBOOK output, it shows the characters æøå correctly in the document text as well as in inline R code. But when the same text is part of an R code chunk, the characters are not shown correctly. It all shows correctly inside RStudio's source window, but not in the preview or an external browser like Chrome or IE.

Here is a minimal reproducible example:

---
title: "R Notebook"
output: html_notebook
---
Dette er en test på om ære være deg i det høyeste er med oss!
Først en chunk:
```{r}
setning <- "Dette er en test på om ære være deg i det høyeste er med oss!"
setning
```
Så en inliner:  `r setning`

This ends up looking like this in the preview:

R Notebook preview

Inspecting the HTML source code, we find:

<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />

The .Rmd file is saved with encoding ISO8859-1. Saving it with UTF-8 makes none of the æøå display correctly.

Some session info:

> sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=Norwegian (Bokmål)_Norway.1252  LC_CTYPE=Norwegian     (Bokmål)_Norway.1252   
[3] LC_MONETARY=Norwegian (Bokmål)_Norway.1252 LC_NUMERIC=C                              
[5] LC_TIME=Norwegian (Bokmål)_Norway.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] lubridate_1.6.0

loaded via a namespace (and not attached):
[1] backports_1.0.4 magrittr_1.5    rprojroot_1.1   htmltools_0.3.5 tools_3.3.2     base64enc_0.1-3 yaml_2.1.14    
[8] Rcpp_0.12.8     rmarkdown_1.2   stringi_1.1.2   knitr_1.15.1    jsonlite_1.1    digest_0.6.10   stringr_1.1.0  
[15] evaluate_0.10 

And

> getOption("encoding")
[1] "native.enc"
Dipu Raj
  • 1,784
  • 4
  • 29
  • 37
Snohan
  • 31
  • 6
  • This sounds like an issue that should hopefully be resolved in the preview release of RStudio: https://www.rstudio.com/products/rstudio/download/preview/ – Kevin Ushey Dec 02 '16 at 14:23
  • 1
    Yes, in the preview release 1.0.136 of RStudio the characters are all displaying correctly! Problem solved, then! Thank you, @KevinUshey. – Snohan Dec 02 '16 at 15:22

1 Answers1

0

Try to use other coding methods. When I wrote θ in my R notebook, I used UTF-8 method which is helpful to display maths symbol.

Qing
  • 1