Based on the xaringan demo presentation, I know that Chinese and other foreign characters should work. However, I can't get console outputs to display correctly for me. I updated xaringan to the development version and updated RStudio to a version from yesterday, but the problem persists.
The console output within RStudio doesn't have any problems. Is this a xaringan or RStudio issue (or a problem with my locale)? Could this be Windows related?
To determine whether RStudio is involved at all, what happens if you call rmarkdown::render() on your sample .Rmd outside of RStudio?
To determine whether this is limited to xaringan, what happens if you render your sample document to a different format? xaringan doesn’t use pandoc, but html_document does, so it would be interesting to know what you get rendering to that format.
Other info that would be helpful to know:
OS version
sessionInfo() after rendering
RStudio version (I know you said you downloaded it yesterday, but that could mean you’re running any of: the latest 1.1 release, the latest 1.2 Preview release, or one of the Dailies)
(I will admit that text encoding problems make me ! So I’m mostly trying to gather info so that somebody with a stronger stomach for them might be able to help )
To clarify one point: how exactly did you generate this document? E.g., were you running R via Rgui.exe?
Also, I’m assuming you are creating your files in RStudio — is that right? If you create a new sample file and explicitly save it with a UTF-8 encoding, are the rendered results any different?
It gets confusing, and it’s not always black or white! I call it a Daily if it came from https://dailies.rstudio.com/, and “the latest Preview release” if it came from https://www.rstudio.com/products/rstudio/download/preview/. As I understand it (from the outside!), things make it to the Preview release page if they’re thought to be in pretty stable shape, while anything goes with the dailies. Anyway, in the end the actual version number is the most informative thing, and unambiguous.
I generated the rmarkdown document both in RStudio via rmarkdown::render() and outside of RStudio via Rgui.exe, with the same results.
Saving the Rmd with UTF-8 explicitly allows me to knit to PDF, but still gets me garbled outputs for pdf/word/html.
Great, thanks for the explanation about dailies/previews! It looks like I downloaded a daily, but it seems like a preview release is probably the better way to go in most cases.
It looks like this is ultimately an issue with R's sink() function, which knitr uses behind the hood (through evaluate) to capture output. For example:
code <- c("中文", "עברית", "english")
conn <- textConnection("output", open = "w", local = TRUE)
sink(conn)
print(code)
close(conn)
sink(NULL)
print(output)