Page 1 of 1

printing \r in a text file

Posted: Tue Feb 27, 2007 4:55 am
by N1gel
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi

I'm writing a Rich Text Format file from php.

I've been experimenting writing it in different ways. at the moment i'm using the fwrite function like so.

Code: Select all

$handle = fopen("newdoc.rtf" , "w");

fwrite ($handle ,"{\rtf1\ansi{\fonttbl\f0\fswiss Helvetica;}\f0
Hello!\par
This is some {\b bold} text.\par
}
");
fclose ($handle);
Now the only problem is when the \r character is written it writes a return carriage.

is there a way i can it write the \r characters without them becoming a new line.

Thanks


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Solved it

Posted: Tue Feb 27, 2007 4:59 am
by N1gel
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Sorry, But i solved this almost as soon as i pressed the post button

it's simply \\r

Code: Select all

$handle = fopen("newdoc.rtf" , "w");

fwrite ($handle ,"{\\rtf1\ansi{\fonttbl\f0\fswiss Helvetica;}\f0
Hello!\par
This is some {\b bold} text.\par
}
");
fclose ($handle);
Thanks


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Tue Feb 27, 2007 5:53 am
by Maugrim_The_Reaper
Bear in mind you'll need to escape all such characters...;)

Posted: Tue Feb 27, 2007 9:23 am
by feyd
Maugrim_The_Reaper wrote:Bear in mind you'll need to escape all such characters...;)
Or use single quote strings. :)