delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/08/05/17:00:35

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <3F301AE1.8CAC9291@dessent.net>
Date: Tue, 05 Aug 2003 14:00:17 -0700
From: Brian Dessent <brian AT dessent DOT net>
Organization: My own little world...
X-Accept-Language: en,en-US
MIME-Version: 1.0
To: "'cygwin AT cygwin DOT com'" <cygwin AT cygwin DOT com>
Subject: Re: Install 1.3.22-1 problem - default text file type - DOS
References: <9B501B3774931C469BCCCC021BE5372277AD58 AT remailnt2-re01 DOT westat DOT com>

Francis Harvey wrote:

> Thanks.  I have now replaced \n with \r\n every place I used \n in a
> character string.  I have made sure not to switch the single character
> when used separately from a string.  Everything appears to work fine
> now.

But that completely misses the point of "text" mode.  You should always
use just "\n" in your strings in the source code, and open any files
containing text in "text" mode i.e. fopen("foo", "rt").  That way, when
you read and write to the file "\n" will be converted to "\r\n" by the
io library, but your code will be portable to any other posix system.

If you explicitly use "\r\n" in your program then you have to make sure
the file is always opened in binary mode otherwise you'll could get
"\r\r\n" as your line delimiter.

Brian

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019