Jump to content


Photo

Funny Line Feeds


  • Please log in to reply
3 replies to this topic

#1 stevepatd

stevepatd
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 19 October 2006 - 03:39 AM

I have a php file that outputs text to a standard ASCII text file.  I put a \n at the end of each line as it writes out.  I then have another php file that reads these generated files and does something with the data.  The problem is, when the second file reads the generated data it doesn't like the \n.  When I edit the generated files with Notepad instead of seeing a carriage return/line feed making the data line up in nice neat columns, I see a little square in place of the \n and the text continues on the same line wrapping at the edge of the screen.

WHat command should I be using to prevent this?

I'm running on a Windows server, either Win2000 or 2003.

Thx,
Steve



#2 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 19 October 2006 - 04:15 AM

nl2br();
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#3 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 19 October 2006 - 06:41 AM

It is because Windows uses a carriage return and then a line feed (\r\n) - CRLF.
Linux uses a line feed (\n) - LF.
Macintosh uses a carriage return (\r) - CR.

#4 btherl

btherl
  • Staff Alumni
  • Advanced Member
  • 3,893 posts
  • LocationAustralia

Posted 19 October 2006 - 07:53 AM

If the file is being created in unix and read in windows, you can probably fix it by using \r\n for linefeed instead of \n.  If it's some other combination, the solution will be different.  nl2br() is for displaying in html, so it doesn't help here.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users