Re: Downloading unix \n text files, convert to \r\n non-unix?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



On Fri, 06 Apr 2007 06:13:59 -0700, Zytan <zytanlithium@xxxxxxxxx> wrote:

On Apr 5, 7:36 pm, Arne Vajhøj <a...@xxxxxxxxxx> wrote:
Zytan wrote:
[...]
It replace \n with \r\n without replacing \r\n with \r\r\n.

Well, \r\r\n wouldn't be proper, anyway, right, so it doesn't really
matter if you fix it or not, since it's already broken?

Your code ensures that only 0 or 1 \r is pre-fixed before \n, before
being replaced with Environment.NewLine, which is always the proper
carraige return for the system running the code. Right?

No. As he said, it replaces \n with \r\n without replacing \r\n with \r\r\n. In ensures that exactly 0 \r is pre-fixed before \n before being replaced, to phrase it in the same way you did.

You are right that \r\r\n would not be proper, which is why he wrote the code to avoid creating instances of that.

Personally, I think it's overkill. If you're going to the trouble of using the general purpose "Environment.NewLine" property as the replaced text, then checking to avoid munging a specific character combination (\r\n) seems pointless, given that in theory the point is that "Environment.NewLine" might not actually be that specific character combination. If nothing else, I would think it would make more sense to design the code to replace *both* \n and \r\n with Environement.NewLine.

But ignoring that point, the code does do exactly what Arne says it does.

Pete
.



Relevant Pages

  • Re: Microsoft Help Centre message
    ... "This memo provides information for the Internet community. ... Oh heres a question for you then tracker, if the character based URL is the ... "proper" name, why does the DNS translate all character based URLs to IP ... "Without Knowledge you have fear, With fear you create your own nightmares." ...
    (alt.computer.security)
  • Re: Validating a Number ID
    ... I am not using data validation. ... Column A has all the IDs that where entered by Users. ... Column B has the Proper formula and Column C has your formula u gave ... > the 9th character ...
    (microsoft.public.excel.newusers)
  • Re: How to terminate a text file line in Unicode (in Java)
    ... stream encoding was set to »UTF-8«, what is the proper, best ... The primary question is how to terminate a line in Unicode. ... It does not define "the" line breaking character. ...
    (comp.std.internat)
  • Re: Contact Form Spam
    ... Yet the proper email has an echo of ... This means that if the abuser inserts a well throught character ... he may make your script compose a message that uses your mail ... I am not using a CAPTCHA. ...
    (comp.lang.php)
  • Re: HTML Hebrew
    ... placement of Hebrew vowel signs ... that it is "private use character", so it cannot be counted on. ... "Proper" ... to make liberal use of dir=rtl attributes to encourage rendering ...
    (comp.fonts)