Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

PHP ascii character problems

  • 28-02-2003 01:35PM
    #1
    Registered Users, Registered Users 2, Paid Member Posts: 14,174 ✭✭✭✭


    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, Registered Users 2 Posts: 6,240 ✭✭✭hussey


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


  • Registered Users, Registered Users 2, Paid Member Posts: 14,174 ✭✭✭✭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, Registered Users 2, Paid Member Posts: 14,174 ✭✭✭✭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