Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

PHP ascii character problems

Options
  • 28-02-2003 1:35pm
    #1
    Registered Users Posts: 14,148 ✭✭✭✭


    Hey guys,

    I've a php script logging some information to a plain text file. This needs to be read by a windows machine.

    I'm logging uid, date and time and then doing a carriage return/newline.

    so the code looks alittle like this:
    $fileUpdate = $gmsCode." - ".getSysDate().chr(13) ;
    

    If I view the log file via browser everything is rosy, but if I try to open the file in a non-*nix environment (ie. Windows), I get the carriage returns printed as little blocks and it's all one big string.

    Any suggestions?


Comments

  • Registered Users Posts: 6,240 ✭✭✭hussey


    try adding in a line feed also
    cause chr$(13) is just carriage return
    chr$(10)


  • Registered Users Posts: 14,148 ✭✭✭✭Lemming


    Nope. Still no joy.

    Even sticking in chr(10) as well doesn't do the job.

    Under windows, I'm still looking at one big uber-string :(


  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    Unix systems use a CR to jump to a new line, whereas Windows expects a CR-LF pair. (CR being a Carriage Return: ASCII 13, \r; LF being a Line Feed or newline: ASCII 10, \n.) If you want the file to view correctly in Windows, send \r\n. Make sure \r\n is in double quotes, otherwise it'll be output literally.
    $fileUpdate = "$gmsCode - " . getSysDate() . "\r\n";
    
    adam


  • Registered Users Posts: 14,148 ✭✭✭✭Lemming


    Cheers adam!

    sorted.

    I appended .(chr(13).chr(10)) ; to the end of the line

    Note, incidentally the "\r\n" doesn't work. Even chr(13).chr(10) doesn't work unless you put a paranthesis around the two of them.


  • Closed Accounts Posts: 286 ✭✭Kev


    Originally posted by dahamsta
    Unix systems use a CR to jump to a new line, whereas Windows expects a CR-LF pair. (CR being a Carriage Return: ASCII 13, \r; LF being a Line Feed or newline: ASCII 10, \n.)

    that should be "Unix systems use a LF"


  • Advertisement
  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    Don't you just hate it when you spend ages trying to get a post right, only to have a simple error pointed out when you're done. Yes, Kev is right, it should have been an LF. Bum. :)

    adam


Advertisement