1

Following recommendations on https://yihui.name/en/2018/11/biggest-regret-knitr, I started saving my .R files with UTF-8 encoding (using RStudios "Save with encoding"). Seems to work well, until it comes to using spin_child.

Under Windows, for example I have a file mainfile.R with this code:

print("Bär 1"); spin_child("subfile.R") 

subfile.R has this code:

print("Bär 2")

In RStudio under Windows, I run

rmarkdown::render("mainfile.R", encoding = "UTF-8")

If both files are saved with encoding UTF-8, Bär 1 comes out fine, but Bär 2 comes out as "Bär 2" (which seems like an encoding problem to me). Interestingly, if I change encoding of subfile.R to ISO-8859-1 (System default), both Bär come out correctly. It seems strange to me that I should have to use different encodings for different files, so I'm wonderning what I have to do if the input file for spin_child ist UTF-8 as well?

Henrik
  • 65
  • 4

1 Answers1

0

This is a bug in knitr, and I just fixed it on Github. Please try the development version and continue using UTF-8:

remotes::install_github('yihui/knitr')
Yihui Xie
  • 28,913
  • 23
  • 193
  • 419