SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Sep 2003
    Location
    USA
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Writing text to file, PHP is adding '\r'

    Hi. I'm writing a string to a file with fwrite(). The string contains the newline '\n' character. After writing the data and reading it back out, I find that a carriage return '\r' was inserted after each newline '\n' for me. To make matters worse, if I construct my string to contain \n\r instead of just \n, \r is added anyway, resulting in \n\r\r.

    Anybody know how to write files without \r being added for you? Is this a feature or a bug?

    Thanks,
    Greg

  2. #2
    Ribbit... Eric.Coleman's Avatar
    Join Date
    Jun 2001
    Location
    In your basement
    Posts
    1,268
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try using the 'b' modifier in fopen()...

    If you are already, take it off.. it makes the open binary safe
    Eric Coleman
    We're consentratin' on fallin' apart
    We were contenders, now throwin' the fight
    I just wanna believe, I just wanna believe in us

  3. #3
    SitePoint Member
    Join Date
    Sep 2003
    Location
    USA
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Zaire
    Try using the 'b' modifier in fopen()...

    If you are already, take it off.. it makes the open binary safe
    Thanks!

  4. #4
    Ribbit... Eric.Coleman's Avatar
    Join Date
    Jun 2001
    Location
    In your basement
    Posts
    1,268
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Am I assuming it worked

    Some Karma would be nice if so
    Eric Coleman
    We're consentratin' on fallin' apart
    We were contenders, now throwin' the fight
    I just wanna believe, I just wanna believe in us

  5. #5
    SitePoint Member
    Join Date
    Sep 2003
    Location
    USA
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Will try it out tonight, but I'm 99% sure this is the solution. - THX


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •