UNIX/Windows text file compatibility

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

    UNIX/Windows text file compatibility

    Hello,

    I guess it's a bit off topic but my script is written in PHP so I
    guess somebody out there could help me.

    I'm facing the well known issue between windows and UNIX related OS.

    The file format is crucial. The file is made on a linux box and as to
    be parsed on a windows box by a commercial software (so I cannot play
    with the code on that side).

    I'm having a problem to mark the end of lines.
    "\n" as you all know doesn't pass well on Windows.

    How could I replace this one:
    fwrite($fichier , "this is a new line\n");

    to make it works with windows?

    Thank you,

    Olivier
  • Tim Van Wassenhove

    #2
    Re: UNIX/Windows text file compatibility

    On 2005-02-28, Olivier Laurent <oliderid@yahoo .co.uk> wrote:[color=blue]
    > I'm having a problem to mark the end of lines.
    > "\n" as you all know doesn't pass well on Windows.
    >
    > How could I replace this one:
    > fwrite($fichier , "this is a new line\n");[/color]

    Winsilly wants you to have it like fwrite($fp, "this is a new
    line\r\n");

    And php has now (since 4.3.10 i believe) a magic constant PHP_EOL

    --
    Met vriendelijke groeten,
    Tim Van Wassenhove <http://www.timvw.info>

    Comment

    • oliderid@yahoo.co.uk

      #3
      Re: UNIX/Windows text file compatibility


      Tim Van Wassenhove wrote:[color=blue]
      > On 2005-02-28, Olivier Laurent <oliderid@yahoo .co.uk> wrote:[color=green]
      > > I'm having a problem to mark the end of lines.
      > > "\n" as you all know doesn't pass well on Windows.
      > >
      > > How could I replace this one:
      > > fwrite($fichier , "this is a new line\n");[/color]
      >
      > Winsilly wants you to have it like fwrite($fp, "this is a new
      > line\r\n");
      >
      > And php has now (since 4.3.10 i believe) a magic constant PHP_EOL
      >
      > --
      > Met vriendelijke groeten,
      > Tim Van Wassenhove <http://www.timvw.info>[/color]

      Bedankt!

      Olivier

      Comment

      Working...