stripping newline from input

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mac

    #16
    Re: stripping newline from input

    On Fri, 03 Sep 2004 14:40:27 +0000, Dan Pop wrote:
    [color=blue]
    > In <pan.2004.09.02 .01.49.53.37717 @bar.net> Mac <foo@bar.net> writes:
    >[color=green]
    >>On Wed, 01 Sep 2004 13:42:01 +0000, Dan Pop wrote:
    >>[snip]
    >>[color=darkred]
    >>> You mean you have used a plain "r" in your fopen call and ended up with
    >>> input lines terminated in \r\n ? In this case, your C programming
    >>> environment is hopelessly broken.
    >>>[/color]
    >>
    >>Well, either that or he somehow created a Windows style text file on a
    >>unix style machine, either by editing it with a windows (or DOS)
    >>application via samba or NFS or something, or by extracting from an
    >>archive of some sort without performing the correct conversion.
    >>
    >>If that is the case, then technically it is not a text file on the
    >>platform where he is reading it, I guess. So there might not necessarily
    >>be anything wrong with the C programming environment.
    >>
    >>This happens often enough that it is worthwhile to deal with it
    >>intelligently , in my opinion.[/color]
    >
    > In my, admitedly, limited experience, Windows implementations return \n
    > when encountering a \n character in the input file. The missing \r
    > doesn't make any difference.
    >
    > Dan[/color]

    I don't know anything to the contrary, although I have noticed that some
    (maybe all?) versions of notepad don't handle \n only lines very well.
    Wordpad does handle these lines just fine, though.

    The case I was thinking of was when you read a windows text file in unix
    land. If you are parsing the file, you should deal with the \r gracefully,
    somehow. I think it should be safe to just ignore it, in this case.

    --Mac

    Comment

    • Dan Pop

      #17
      Re: stripping newline from input

      In <cha4le0kug@new s3.newsguy.com> mwojcik@newsguy .com (Michael Wojcik) writes:

      [color=blue]
      >In article <ch4jj9$1k8$15@ sunnews.cern.ch >, Dan.Pop@cern.ch (Dan Pop) writes:[color=green]
      >> In <ch48f3$ri3$1@n ewstree.wise.ed t.ericsson.se> "John Smith" <soneone@micros oft.com> writes:
      >>[color=darkred]
      >> >That may be it: someone else has written wrappers for basic things like
      >> >fopen (to give support for off-system storage, so don't shoot it down just
      >> >yet...) which I've had to start using. They may be opening it as binary, I
      >> >don't know (but will check, and then reach for the shotgun).[/color]
      >>
      >> You mean you have used a plain "r" in your fopen call and ended up with
      >> input lines terminated in \r\n ?[/color]
      >
      >I took his comment to mean that someone wrote the code that calls
      >fopen ("someone else has written wrappers for basic things like
      >fopen"), and that someone may have used "rb" ("They may be opening it
      >as binary"). Indeed, that continues to strike me as the most likely
      >interpretati on of what John wrote.[/color]

      Yet, these wrappers must be called, in order to have the file opened.
      And I would expect such a wrapper to also take a mode parameter, in order
      to be of any real use to the programmer.

      Dan
      --
      Dan Pop
      DESY Zeuthen, RZ group
      Email: Dan.Pop@ifh.de

      Comment

      Working...