简体   繁体   English

Rscript.exe中带有Unicode字符的文件路径

[英]File path with Unicode characters in Rscript.exe

I'm trying to save an SVG image to a file path containing Unicode characters. 我正在尝试将SVG图像保存到包含Unicode字符的文件路径。 For example: 例如:

n = c(2, 3, 5)
s = c("aa", "bb", "cc") 
b = c(TRUE, FALSE, TRUE) 
df = data.frame(n, s, b)

svg("c:/נועם/plots.svg")
plot(df)
dev.off() 

Running this with Rscript.exe fails with the following error: 使用Rscript.exe运行此命令失败,并显示以下错误:

Error in plot.new() : cairo error 'error while writing to output stream' plot.new()中的错误:开罗错误“写入输出流时出错”

How can I make it work? 我该如何运作?

You can set working directory to the directory with Hebrew name than save svg file. 您可以将工作目录设置为希伯来语名称的目录,而不是保存svg文件。 Please see the code below: 请参见下面的代码:

n <- c(2, 3, 5)
s <- c("aa", "bb", "cc") 
b <- c(TRUE, FALSE, TRUE) 
df <- data.frame(n, s, b)
setwd("C:\\נועם\\")
svg("plots.svg")
plot(df)
dev.off() 

Late to the party but I think that wrapping the path in enc2native() function normally solves encoding issues under Windows to my experience. 聚会晚了,但是我认为将路径包装在enc2native()函数中通常可以解决Windows的编码问题。 In your case you should try 在您的情况下,您应该尝试

svg(enc2native("c:/נועם/plots.svg"))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM