This is a drop in replacement for base::writeLines()
with restricted
functionality. Compared to base::writeLines()
it:
Only works with file paths, not connections.
Uses enc2utf8()
to convert text()
to UTF-8 before writing.
Uses sep
unconditionally as the line ending, regardless of platform.
The useBytes
argument is ignored, with a warning.
writeLines(text, con, sep = "\n", useBytes)
The UTF-8 encoded input text (invisibly).
tf <- tempfile()
writeLines(rownames(mtcars), tf)
# Trying to use connections throws an error
con <- file(tf)
try(writeLines(con))
#> Error in writeLines(con) : argument "con" is missing, with no default
close(con)
# Trying to use unsupported args throws a warning
writeLines(rownames(mtcars), tf, useBytes = TRUE)
#> Warning: `useBytes` is ignored by brio::writeLines()
unlink(tf)