Newbie Question re Line Breaks

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I'm working on a script that generates and sends emails, and it looks like
I have to use \r\n for line breaks in the message body for correct display
in Windows email clients.

If the send fails [mail() = false], I save the message to an XML file, and
attempt a re-send later.

Is it OK to save the body with \r\n line breaks, or will this mess up
reading the file later with fgets()? How does fgets() deal with \r\n line



Re: Newbie Question re Line Breaks

Pete wrote:
Quoted text here. Click to load it


fgets does nothing with line breaks on unix/linux systems. However, it
converts line breaks on windows systems, when the file handler was
opened in text mode. Please have a look at :
"Note:  Different operating system families have different line-ending
conventions. When you write a text file and want to insert a line
break, you need to use the correct line-ending character(s) for your
operating system. ... Windows offers a text-mode translation flag ('t')
which will transparently translate \n to \r\n when working with the
file. In contrast, you can also use 'b' to force binary mode, which
will not translate your data."


Site Timeline