Re: Downloading unix \n text files, convert to \r\n non-unix?
- From: Arne Vajhøj <arne@xxxxxxxxxx>
- Date: Wed, 04 Apr 2007 21:53:30 -0400
Arne Vajhøj wrote:
Zytan wrote:Should I do a String.Replace(), or is there a better solution?
String.Replace("\n", "\r\n") doesn't work. It doesn't change
anything.
It should.
string s = "A\nBB\nCCC";
Console.WriteLine(s.Length);
s = s.Replace("\n", "\r\n");
Console.WriteLine(s.Length);
prints 8 and 10 for me !
But I think:
string s = "A\nBB\nCCC";
Console.WriteLine(s.Length);
s = Regex.Replace(s, "(?<!\r)\n", Environment.NewLine);
Console.WriteLine(s.Length);
is better code !
Arne
.
- Follow-Ups:
- References:
- Prev by Date: Re: Downloading unix \n text files, convert to \r\n non-unix?
- Next by Date: Re: Top posting
- Previous by thread: Re: Downloading unix \n text files, convert to \r\n non-unix?
- Next by thread: Re: Downloading unix \n text files, convert to \r\n non-unix?
- Index(es):