Encoding Gnuplot读取的不是区域设置编码文件
我想将ISO_8859_1编码文件的数据绘制为两列数字。这些是文件的前10个数据点:Encoding Gnuplot读取的不是区域设置编码文件,encoding,plot,gnuplot,iso-8859-1,Encoding,Plot,Gnuplot,Iso 8859 1,我想将ISO_8859_1编码文件的数据绘制为两列数字。这些是文件的前10个数据点: #Pe2 1 0.8000 2 0.8000 3 0.8000 4 0.8000 5 0.8000 6 0.8000 7 0.8000 8 0.8000 9 0.8000 10 0.8000 原始文件有15000个
#Pe2
1 0.8000
2 0.8000
3 0.8000
4 0.8000
5 0.8000
6 0.8000
7 0.8000
8 0.8000
9 0.8000
10 0.8000
原始文件有15000个数据点。我用MATLAB创建这些数据,特别是设置ISO_8859_1编码,所以我确信这就是编码。这是一段matlab代码:
slCharacterEncoding('ISO-8859-1'); %Instruction before writing anything to the file.
fprintf(fileID,' %7d %7.4f',Tempo(i),y(i)); %For loop in this instruction
fprintf(fileID,'\r'); %Closing the file
fclose(fileID);
这是我运行的脚本。此文件使用默认的Windows txt文件编码:
set encoding iso_8859_1
set terminal wxt size 1000,551
# Line width of the axes
set border linewidth 1.5
# Line styles
set style line 1 lc rgb '#dd181f' lt 1 lw 1 pt 0 # red
# Axes label
set xlabel 'tiempo'
set ylabel 'valor'
plot 'Pe2.txt' with lines ls 1
G N U P L O T
Version 4.6 patchlevel 5 last modified February 2014
Build System: MS-Windows 32 bit
Copyright (C) 1986-1993, 1998, 2004, 2007-2014
Thomas Williams, Colin Kelley and many others
gnuplot home: http://www.gnuplot.info
faq, bugs, etc: type "help FAQ"
immediate help: type "help" (plot window: hit 'h')
Terminal type set to 'wxt'
gnuplot> cd 'C:\Example'
gnuplot> load 'script.txt'
"script.txt", line 10: warning: Skipping data file with no valid points
gnuplot> plot 'Pe2.txt' with lines ls 1
^
"script.txt", line 10: x range is invalid
gnuplot> show encoding
nominal character encoding is iso_8859_1
however LC_CTYPE in current locale is Spanish_Spain.1252
gnuplot>
这是我运行脚本时gnuplot控制台的输出。之后,我输入show编码:
set encoding iso_8859_1
set terminal wxt size 1000,551
# Line width of the axes
set border linewidth 1.5
# Line styles
set style line 1 lc rgb '#dd181f' lt 1 lw 1 pt 0 # red
# Axes label
set xlabel 'tiempo'
set ylabel 'valor'
plot 'Pe2.txt' with lines ls 1
G N U P L O T
Version 4.6 patchlevel 5 last modified February 2014
Build System: MS-Windows 32 bit
Copyright (C) 1986-1993, 1998, 2004, 2007-2014
Thomas Williams, Colin Kelley and many others
gnuplot home: http://www.gnuplot.info
faq, bugs, etc: type "help FAQ"
immediate help: type "help" (plot window: hit 'h')
Terminal type set to 'wxt'
gnuplot> cd 'C:\Example'
gnuplot> load 'script.txt'
"script.txt", line 10: warning: Skipping data file with no valid points
gnuplot> plot 'Pe2.txt' with lines ls 1
^
"script.txt", line 10: x range is invalid
gnuplot> show encoding
nominal character encoding is iso_8859_1
however LC_CTYPE in current locale is Spanish_Spain.1252
gnuplot>
如果我打开文件,进行一些更改撤消更改并保存文件,gnuplot将打印文件。我猜这是因为它使用本地编码保存它,而gnuplot使用本地编码读取文件
如何使用gnuplot打印不使用本地编码格式的文件
当我使用VS2010Css输出文件时,我也遇到了类似的问题。如果我没有特别设置文化:
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US");
Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US");
我无法保存gnuplot能够打印的文件。我相信最后一个问题是因为,和
在Css中,我使用以下命令保存文件:
StreamWriter Writer = new StreamWriter(dir + @"\" + + (k+1) + "_" + nombre + extension);
Writer.WriteLine("#" + (k+1) + "_" + nombre);
Writer.WriteLine();
Writer.WriteLine("{0,32} {1,32}", "#tiempo", "#valor");
for (int i = 0; i < tiempo.GetLength(0); i++)
{
Writer.WriteLine("{0,32} {1,32}", tiempo[i].ToString(), valor[i, k]);
}
谢谢。您的文件只有回车符\r 0xd作为换行符,这不适用于gnuplot。您必须只使用换行符0xa,但\r\n也可以使用。请说明您在做什么。有太多可能出错的地方。。。显示一个最小的数据文件和一个简短的、可运行的脚本,其中显示了问题,包括终端设置等。我想已经完成了。如果你还想要什么,现在就让我来。非常感谢。很难找到错误源。我知道,字节顺序标记BOM会导致问题,但错误消息应该不同。否则,编码应该不会有问题,因为您只打印数字而没有标签。你能把一个完整的有问题的文件上传到某个地方吗?我已经把完整的文件上传到了我找到的第一个网站上,这里是链接:谢谢你花时间。