Raised This Month: $ Target: $400
 0% 

reading line ( linux & windows line format )


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 09-21-2014 , 23:37   reading line ( linux & windows line format )
Reply With Quote #1

Hello everyone!

here's my code:
PHP Code:
    new fopen(file"rt")
    while (
&& !feof(f))
    {
        
fgets(ftemp21023)
        
replace(temp21023"^n""")
    } 
The thing is that it will fail if i load window line format files on linux...
what do i mean by linux&window line format:

window's one:
[IMG]http://s29.************/8wigyi987/window.png[/IMG]
line: 13 10 or 0D0A ( 2 bytes )

linux's one:
[IMG]http://s13.************/f4nkzitjr/linux.png[/IMG]
line: 10 or 0A ( 1 byte )

for example loading windows lines in linux will cause fgets to get whole file, i assume that because
while i was debugging the code, loop did only one cycle.
I dont know how windows will react to linux lines, never tried it. Didn't find it that important i guess...
Anyideas how to fix my problem here?

Thanks!


edit:
one solution would be using fread i guess.
Calling fread for every char but this is just too bad, i better code module and parse things there but i was hoping there's another way.

Last edited by .Dare Devil.; 09-21-2014 at 23:40.
.Dare Devil. is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:20.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode