Skip to content

Commit

Permalink
Try hard to encode the final file
Browse files Browse the repository at this point in the history
  • Loading branch information
dieghernan committed Mar 12, 2024
1 parent d2214d3 commit 5167c48
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion R/cff_write.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ cff_write <- function(x, outfile = "CITATION.cff", keys = list(),
}


# See https://github.com/r-universe-org/help/issues/382
# Write CITATION with comment
com <- c(
"# --------------------------------------------",
Expand All @@ -103,7 +104,10 @@ cff_write <- function(x, outfile = "CITATION.cff", keys = list(),
" "
)

full_text <- c(com, yaml::as.yaml(citat))
# MAX effort to get right the encoding
com <- enc2utf8(com)
out_yaml <- enc2utf8(capture.output(print(citat)))
full_text <- enc2utf8(c(com, out_yaml, ""))
fh <- file(outfile, encoding = encoding)
on.exit(if (isOpen(fh)) close(fh))
writeLines(full_text, fh)
Expand Down

0 comments on commit 5167c48

Please sign in to comment.