Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在 Windows 环境中使用 R。当我使用sink将输出定向到文件时,我无法将编码设置为 UTF-8。
sink
sink("Umlaute.tex", append=FALSE, split=TRUE) cat("ÄÖÜäöüß") sink()
如何将输出编码设置为 UTF-8?
您可以先打开一个具有正确编码的连接,然后再连接到该连接。这也允许更多地控制文件的打开方式。
con <- file("Umlaute.tex", open = "wt", encoding = "UTF-8") sink(con, split = T) cat("ÄÖÜäöüß") sink() close(con)