Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Rscript.exe中包含Unicode字符的文件路径_R_Svg_Unicode_Filesystems_Rscript - Fatal编程技术网

Rscript.exe中包含Unicode字符的文件路径

Rscript.exe中包含Unicode字符的文件路径,r,svg,unicode,filesystems,rscript,R,Svg,Unicode,Filesystems,Rscript,我正在尝试将SVG图像保存到包含Unicode字符的文件路径。例如: 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() 使用Rscript.exe运行此操作失败,错误如下: plot.new()中出错:cairo错误“写入输出流时出错” 如何使其工作?您可以将工作目录设置为

我正在尝试将SVG图像保存到包含Unicode字符的文件路径。例如:

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() 
使用Rscript.exe运行此操作失败,错误如下:

plot.new()中出错:cairo错误“写入输出流时出错”


如何使其工作?

您可以将工作目录设置为具有希伯来语名称的目录,而不是保存svg文件。请参阅下面的代码:

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() 

n晚会迟到了,但根据我的经验,将路径包装在
enc2native()
函数中通常可以解决Windows下的编码问题。对你来说,你应该试试

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

看起来像是Windows问题。我建议首先不要用希伯来语创建目录名。根据我的经验,完全用英语工作是最安全的做法,以避免此类问题和其他许多潜在问题。另外,看看当您使用
normalizePath(“c:/נועם/plots.svg”)
希伯来语时会发生什么,作为一个例子。脚本试图写入用户本地文件夹(c:/users/),当帐户用户名包含Unicode字符时,我遇到了此错误。@Noamberar作为系统管理员,我将备份David的建议,不要使用ascii字母以外的任何字符。使用unicode的用户名会导致问题,主目录很难管理,NTFS上的权限有时会挂起,等等。要修复您的脚本,请在用户的主目录以外的其他位置写入。若安全性/权限是一个问题,那个么管理它们,而不是依赖文件末尾的“应该”状态,因为无论如何都不能保证它。