Closed lancearius163 closed 3 years ago
stri_write_lines
is implemented as follows:
function (str, fname, encoding = "UTF-8", sep = ifelse(.Platform$OS.type ==
"windows", "\r\n", "\n"))
{
str <- stri_join(str, sep, collapse = "")
str <- stri_encode(str, "", encoding, to_raw = TRUE)[[1]]
writeBin(str, fname, useBytes = TRUE)
invisible(NULL)
}
I think the easiest approach would be to open a string connection (see textConnection
), call write.csv()
on it, apply a conversion with stri_encode
and call writeBin
Do you have a concrete (reproducible) example where setting the fileEncoding
argument of read.csv
or read.table
does not give you the correct output?
(closing due to inactivity)
The Stri_write_lines function is very useful for me to export files in Chinese from R to windows via txt files. However I am going to write a csv file of tables with Chinese, is there any similar functions that I can use? Thank you!