PDA

View Full Version : txt didnt recognize \t either ???


black
03-06-2003, 08:28 AM
Gosh I wrote strings with \t and \n to a text file with function fwrite, finally I got single space instead of those symbols, what's up ??? :confused:

freddycodes
03-06-2003, 03:35 PM
Any number of things could have happened, how were you looking at the text file to see if the tabs and linebreaks were in it? Could you possibly post your code, so we might have a slightly better chance ad figuring out what happened.

black
03-11-2003, 07:29 AM
Originally posted by freddycodes
Any number of things could have happened, how were you looking at the text file to see if the tabs and linebreaks were in it? Could you possibly post your code, so we might have a slightly better chance ad figuring out what happened.

my code is something like this:
<?
$str="a\tb\rc\nd\r\n\e";
fwrite($handle, $str); // $handle is the handle of the file already opened~
?>

but finally that text file display: a b c d e, what's wrong ??? :confused:

CyanBlue
03-11-2003, 08:12 AM
I think this is the code that I have mentioned last time...<?php
$FileName = "./deleteMe.txt";
@unlink($FileName);
$FilePointer = fopen ($FileName, "w");
$output = "a\tb<p>\tb\rc\nd\r\ne";
echo ($output);
fwrite ($FilePointer, $output);
fclose ($FilePointer);
?>I get to see this in the browsera b

b c d eand I get to see this in the deleteMe.txt with proper tabs between 'a' and 'b' and 'b' and 'b'...a b<p> b
c
d
eCheck it out... ;)

freddycodes
03-11-2003, 03:18 PM
Jason,

That is precisely what I was getting at when I asked them how they were veiwing the text file.

CyanBlue
03-11-2003, 07:37 PM
^^; (Pretending what Masta is trying to say here... cuz Jason has no idea what he's talking about...)

Hm... You mean the output result varies depending on where the result is written??? Like HTML tag doesn't work how it is supposed to work within the ASCII text file, like my <p> example??? (I hope it is, since that is the only case I can think of...) :D

freddycodes
03-11-2003, 07:42 PM
No no, that \t \n have no effect in a browser, like you said. However viewing it in say notepad on windows would show the spaces. Or reading the txt file into html with a server-side scripting language and wrapping it in <pre> tags would also do it.

CyanBlue
03-11-2003, 08:27 PM
Ah... I see... Thanks for the tip, Masta... :D

black
03-13-2003, 06:44 AM
Originally posted by freddycodes
No no, that \t \n have no effect in a browser, like you said. However viewing it in say notepad on windows would show the spaces. Or reading the txt file into html with a server-side scripting language and wrapping it in <pre> tags would also do it.

windows ??? you mean it is different from Unix or Linux ? :rolleyes:

freddycodes
03-13-2003, 03:05 PM
windows ??? you mean it is different from Unix or Linux ?


No no, notepad is a windows application, so I said for example notepad on windows.

black
03-19-2003, 07:57 AM
Originally posted by freddycodes
No no, notepad is a windows application, so I said for example notepad on windows.

then how could I fix it please ? :rolleyes:

CyanBlue
03-19-2003, 08:24 AM
Use different text editor, I guess???

This is what I see on the DOS window...c b<p> b
d
eThere are 7 spaces between 'c' and 'b', and 4 spaces between '<p>' and 'b'... Note that 'a' is gone... 3 lines output...

This is what I see on the notepad...a b<p> b*c*d
eThe spaces between 'a' and 'b', and '<p>' and 'b' are all tab character... Notice that * between 'b' and 'c', and 'c' and 'd'??? I see a square box within the nopepad and I am just representing it with the *... 2 lines output...

This is what I see on the TextPad...a b<p> b
c
d
eThere are two tab characters properly, and lines are showing as it should be... 4 line output...

black
03-25-2003, 06:18 AM
thnx Cyan but to me the only text editor in handy is notepad. :o

CyanBlue
03-25-2003, 06:46 AM
At work??? Try WordPad instead... I just tried it and I see the same result as TextPad... Of course you have to make sure that you are saving the file in the right format... ;)

black
03-26-2003, 04:33 AM
Originally posted by CyanBlue
At work??? Try WordPad instead... I just tried it and I see the same result as TextPad... Of course you have to make sure that you are saving the file in the right format... ;)

thanx Cyan~ :)