General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old October 2nd, 2002, 04:52 AM
freeland freeland is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: BE
Posts: 4 freeland User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
New line caariage return

I want to generate some files at my job on a NT machine. When I press the button "SAVE" I want the file to be saved on a UNIX machine by sending it by FTP.
This is working well but when I'm opening the file on the UNIX machine I see a square on the place where you should have a carriage return. When I'm opening the file on the NT machine I don't see squares (control characters).

I tried to send the file in FTP_Binary and in FTP_ASCII but I have the problem in the two cases.

The text I am sending is like:
$textfield="Hello this is a test\n This is a test2\n And a lot more";
$fp = fopen($temp, "w+");
$write=fwrite($fp, $textfield);

I tried to upload the generated files with an ordinarry FTP program (like WSFTP) and there I didn't encounter this problem //AND i saved my file as unix format with textpad and uploaded it with my FTP script. (FTP program does auto convert the file to unix format)
So i want to do the DOS format to UNIX format conversion it with a script.
I read in a nwsgrp that WIN machine = \r\n and on Unix machine = \n. (new line)
But I am saving it with "\n", so this is the format for an UNIX machine.

When I open my file with a hex editor on windows i see OD OA = \r\n. So it seems that Windows automatically adds the \r.
I tried then to use $textfield=str_replace("\r\n","\n",$textfield);
But still the same problem.
CAN PLEASE SOMEONE HELP ME.
Thanks in advance,
Frederick

Reply With Quote
  #2  
Old October 2nd, 2002, 11:52 AM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 7
Try:

$textfield = preg_replace("/(\015\012)|(\015)|(\012)/","",$textfield);

or maybe:

$textfield = preg_replace("/(\015\012)|(\015)|(\012)/","\n",$textfield);

Reply With Quote
  #3  
Old October 3rd, 2002, 12:37 PM
freeland freeland is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: BE
Posts: 4 freeland User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
The solution

I found the solution. I have to open my file binary to write:
fopen ($test,wb+)

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > New line caariage return


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT