how to force data.table to save data in utf8?

library(data.table)
dt <- data.table(x = c("\u00f4", "T\u00fCrkiye"), stringsAsFactors = FALSE)
data.table::fwrite(dt, "DF.csv", bom = TRUE)

cat("Header\n", file = "DF.csv")
data.table::fwrite(dt, file = "DF.csv", append = TRUE, col.names = TRUE, bom = TRUE)

image

image
i want to edit the second chunck of code to add header in top of the file.
Thanks

library(data.table)
dt <- data.table(x = c("\u00f4", "T\u00fCrkiye"), stringsAsFactors = FALSE)
cat("\xEF\xBB\xBF",file="DF.csv")
cat("Header\n", file = "DF.csv",append = TRUE)
data.table::fwrite(dt, file = "DF.csv", append = TRUE, col.names = TRUE)
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.