【发布时间】:2013-02-08 05:32:22
【问题描述】:
我注意到 GitHub for windows 报告了一些我认为不应该更改的文件。 问题出现在我们的应用程序中读取的一些 .txt 文件中。运行程序后,报告所有读取的 .txt 文件的每一行结尾都加倍: 例如:
Line1
Line2
变成
Line1
Line2
我有一种感觉,这是由于某些行尾问题,可能是 git 中的错误设置,所以我查看了 Notepad++ 显示所有字符。在运行程序之前,文件如下所示:
Line1 CRLF
Line2 CRLF
Line3
然后,他们变成:
Line1 CR
CRLF
Line2 CR
CRLF
Line3
因此,GH4W 报告它们已更改似乎是正确的。问题是,他们不应该这样。 我正在使用这样的 StreamReader 阅读它们:
// ASCII.RodBarcodes holds path to RodBarcodes.txt
using (StreamReader sr = new StreamReader(ASCII.RodBarcodes))
{
int count = 0;
string line = sr.ReadLine();
while (line != null)
{
Rods.Add(new AnemometerRod());
Rods[count].Barcode = line;
line = sr.ReadLine();
count++;
}
}
这些额外的 CR 来自哪里?
【问题讨论】:
标签: git streamreader line-endings