Skip to content

Commit

Permalink
ensure as_tmpfile encoding = "UTF-8"
Browse files Browse the repository at this point in the history
  • Loading branch information
dpprdan committed Jun 25, 2018
1 parent 7f43aeb commit ece0159
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion R/utils.R
@@ -1,8 +1,11 @@
# return a string as a tempfile
as_tmpfile <- function(str) {
if (length(str) > 0) {
str <- enc2utf8(str)
str_tmpfile <- tempfile("rmarkdown-str", fileext = ".html")
writeLines(str, str_tmpfile, useBytes = TRUE)
con <- file(str_tmpfile, open = "w+", encoding = "native.enc")
writeLines(str, con = con, useBytes = TRUE)
close(con)
str_tmpfile
} else {
NULL
Expand Down

0 comments on commit ece0159

Please sign in to comment.