content-type woes and the evils of /n -- any advice?

content-type woes and the evils of /n -- any advice?

am 08.12.2006 23:40:40 von Todd Morrison

--===============1382171905==
Content-type: text/html; charset=us-ascii
Content-transfer-encoding: 7BIT



Hello Everyone!


I've written a file-converter that grabs what is essentially a CSV file,
and spews it out in a reformatted fashion. Each line of the
"CSV" is terminated by a newline, and must be reproduced in the
conversion. However, I've hit a wall.


The converter works flawlessly when run from the command line. The
problem is that the web version of the converter, which uses the same
code as the command-line version, does not reproduce the newlines
properly, and thus, the downloaded file does not have the newlines where
they should be -- that is, there are no newlines in the downloaded file
at all.


Just to give you an idea of what I'm doing...


The web version of the converter loads the file that needs to be
converted into @converto, coverts the data, and then the following is
passed to the browser:


print
"Content-type:text/html\n";

print
" Content-Disposition:attachment;filename=convertedFile.txt\n\ n ";

print @converto;


Is there a way to have the newlines faithfully reproduced? I've tried
various Content-encodings (i.e. quoted-printable, base7, even binary) and
the results are always the same (no newlines reproduced). Attempts to
force newlines with a for loop, i.e.:


foreach (@converto) { print "$_\n"; }  # I've tried:
\n\r  \n\n   \n\r\n\r


Will produce random newlines, but the converted file remains
"broken".


Any advice would be super-appreciated...


Thanks!


Todd









--===============1382171905==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============1382171905==--

Re: content-type woes and the evils of /n -- any advice?

am 09.12.2006 00:38:42 von Williamawalters

--===============0760832945==
Content-Type: multipart/alternative;
boundary="-----------------------------1165621122"


-------------------------------1165621122
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit


hi todd --

In a message dated 12/8/2006 5:41:24 P.M. Eastern Standard Time,
reptile@uwo.ca writes:

> Hello Everyone!
>
> I've written a file-converter that grabs what is essentially a CSV file,
> and spews it out in a reformatted fashion. Each line of the "CSV" is
> terminated by a newline, and must be reproduced in the conversion. However,
> I've hit a wall.
>
> The converter works flawlessly when run from the command line. The problem
> is that the web version of the converter, which uses the same code as the
> command-line version, does not reproduce the newlines properly, and thus,
> the downloaded file does not have the newlines where they should be -- that
> is, there are no newlines in the downloaded file at all.
>
> Just to give you an idea of what I'm doing...
>
> The web version of the converter loads the file that needs to be converted
> into @converto, coverts the data, and then the following is passed to the
> browser:
>
> print "Content-type:text/html\n";
> print "Content-Disposition:attachment;filename=convertedFile.txt\n \n";
> print @converto;
>
> Is there a way to have the newlines faithfully reproduced? I've tried
> various Content-encodings (i.e. quoted-printable, base7, even binary) and
> the results are always the same (no newlines reproduced). Attempts to force
> newlines with a for loop, i.e.:
>
> foreach (@converto) { print "$_\n"; } # I've tried: \n\r \n\n \n\r\n\r
>
> Will produce random newlines, but the converted file remains "broken".
>
> Any advice would be super-appreciated...
>
> Thanks!
>
> Todd


if you're trying to put line breaks into html content that will be displayed
in a
browser, try using "
". e.g.,

foreach (@converto) { print "$_
"; } # browser line break

_http://www.htmlhelp.com/reference/html40/alist.html_
(http://www.htmlhelp.com/reference/html40/alist.html) has info on html elements.

hth -- bill walters



-------------------------------1165621122
Content-Type: text/html; charset="US-ASCII"
Content-Transfer-Encoding: quoted-printable





Arial"=20
bottomMargin=3D7 leftMargin=3D7 topMargin=3D7 rightMargin=3D7> e_document=20
face=3DArial color=3D#000000 size=3D2>


hi todd --  

 

In a message dated 12/8/2006 5:41:24 P.M. Eastern Standard Time,=20
reptile@uwo.ca writes:

 

> Hello Everyone!
>
> I've written a file-converter tha=
t=20
grabs what is essentially a CSV file,
> and spews it out in a reformat=
ted=20
fashion. Each line of the "CSV" is
> terminated by a newline, and must=
be=20
reproduced in the conversion. However,
> I've hit a wall.
>
=
>=20
The converter works flawlessly when run from the command line. The=20
problem
> is that the web version of the converter, which uses the sam=
e=20
code as the
> command-line version, does not reproduce the newlines=20
properly, and thus,
> the downloaded file does not have the newlines w=
here=20
they should be -- that
> is, there are no newlines in the downloaded f=
ile=20
at all.
>
> Just to give you an idea of what I'm doing...
&g=
t;=20

> The web version of the converter loads the file that needs to be=20
converted
> into @converto, coverts the data, and then the following i=
s=20
passed to the
> browser:
>
> print=20
"Content-type:text/html\n";
> print=20
"Content-Disposition:attachment;filename=3DconvertedFile.txt \n\n";
> p=
rint=20
@converto;
>
> Is there a way to have the newlines faithfully=20
reproduced? I've tried
> various Content-encodings (i.e. quoted-printa=
ble,=20
base7, even binary) and
> the results are always the same (no newlines=
=20
reproduced). Attempts to force
> newlines with a for loop, i.e.:
&g=
t;=20

> foreach (@converto) { print "$_\n"; }  # I've tried: \n\r =
;=20
\n\n   \n\r\n\r
>
> Will produce random newlines, but=
the=20
converted file remains "broken".
>
> Any advice would be=20
super-appreciated...
>
> Thanks!
>
> Todd
V>
 

if you're trying to put line breaks into html content that will be=20
displayed in a

browser, try using "<br>".   e.g.,  

 

   foreach (@converto) { print "$_<br>"; }  =20=
#=20
browser line break

 

href=3D"http://www.htmlhelp.com/reference/html40/alist.html" >http://www.html=
help.com/reference/html40/alist.html has=20
info on html elements.  

 

hth -- bill walters  

 


-------------------------------1165621122--

--===============0760832945==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============0760832945==--

Re: content-type woes and the evils of /n -- any advice?

am 09.12.2006 00:47:43 von intertwingled

Williamawalters@aol.com wrote:
>
> hi todd --
>
> In a message dated 12/8/2006 5:41:24 P.M. Eastern Standard Time,
> reptile@uwo.ca writes:
>
>> Hello Everyone!
>>
>> I've written a file-converter that grabs what is essentially a CSV file,
>> and spews it out in a reformatted fashion. Each line of the "CSV" is
>> terminated by a newline, and must be reproduced in the conversion. However,
>> I've hit a wall.
>>
>> The converter works flawlessly when run from the command line. The problem
>> is that the web version of the converter, which uses the same code as the
>> command-line version, does not reproduce the newlines properly, and thus,
>> the downloaded file does not have the newlines where they should be -- that
>> is, there are no newlines in the downloaded file at all.
>>
>> Just to give you an idea of what I'm doing...
>>
>> The web version of the converter loads the file that needs to be converted
>> into @converto, coverts the data, and then the following is passed to the
>> browser:
>>
>> print "Content-type:text/html\n";
>> print "Content-Disposition:attachment;filename=convertedFile.txt\n \n";
>> print @converto;
>>
>> Is there a way to have the newlines faithfully reproduced? I've tried
>> various Content-encodings (i.e. quoted-printable, base7, even binary) and
>> the results are always the same (no newlines reproduced). Attempts to force
>> newlines with a for loop, i.e.:
>>
>> foreach (@converto) { print "$_\n"; } # I've tried: \n\r \n\n \n\r\n\r
>>
>> Will produce random newlines, but the converted file remains "broken".
>>
>> Any advice would be super-appreciated...
>>
>> Thanks!
>>
>> Todd
>
>
> if you're trying to put line breaks into html content that will be displayed
> in a
> browser, try using "
". e.g.,
>
> foreach (@converto) { print "$_
"; } # browser line break
>
> _http://www.htmlhelp.com/reference/html40/alist.html_
> (http://www.htmlhelp.com/reference/html40/alist.html) has info on html elements.
>
> hth -- bill walters
>
>
>
>
>
> ------------------------------------------------------------ ------------
>
> _______________________________________________
> ActivePerl mailing list
> ActivePerl@listserv.ActiveState.com
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

There is also the

tag that you can try. Put it at the very <br /> top of the document and the rest of the document is interpreted as text, <br /> not html. You can also try giving the downloaded file a .txt suffix.<br /> <br /> Tony<br /> <br /> -- <br /> <br /> I always have coffee when I watch radar!<br /> _______________________________________________<br /> ActivePerl mailing list<br /> ActivePerl@listserv.ActiveState.com<br /> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs</p> </article> <article> <h2>Re: content-type woes and the evils of /n -- any advice?</h2><span>am 09.12.2006 01:25:50 von Todd Morrison</span> <p>I would like to thank everyone for their help... Mark, Bill, and Anthony. <br /> I really do appreciate it! Such wonderful assistance, on a Friday no less!<br /> <br /> I have a feeling that my blabber-some e-mail was a bit vague. Essentially, <br /> the web-version of the converter pushes a download through the browser, and <br /> newlines must be reproduced in the downloaded file for use with a <br /> third-party desktop application (which is very persnickety about placement <br /> of newlines to the point of hair-pulling -- that and the file must be <br /> purely text; no HTML allowed).<br /> <br /> When I input the source file ("file to be converted") into the command-line <br /> converter it produces the converted file, which is 1.01KB in size. The web <br /> version of the converter produces a 1.00KB file, which the third-party <br /> application refuses to open. I've done a line-by-line comparison of the the <br /> converted files (a simple $a eq $b test), and Perl reports that both files <br /> are identical, yet the operating system reports a 1 byte difference. This <br /> difference is increased if the source file is larger, of course. And of <br /> course, this difference is being sniffed out by the third-party app which <br /> refuses to play nice.<br /> <br /> Again, thanks for your help, gentlemen! If you have any further ideas <br /> (sledgehammer suggestions are welcomed), I'd love to read about them.<br /> <br /> Have a great night!<br /> <br /> Todd<br /> <br /> <br /> <br /> At 07:00 PM 08/12/2006, Anthony R. Nemmer wrote:<br /> >Williamawalters@aol.com wrote:<br /> > ><br /> > > hi todd --<br /> > ><br /> > > In a message dated 12/8/2006 5:41:24 P.M. Eastern Standard Time,<br /> > > reptile@uwo.ca writes:<br /> > ><br /> > >> Hello Everyone!<br /> > >><br /> > >> I've written a file-converter that grabs what is essentially a CSV file,<br /> > >> and spews it out in a reformatted fashion. Each line of the "CSV" is<br /> > >> terminated by a newline, and must be reproduced in the conversion. <br /> > However,<br /> > >> I've hit a wall.<br /> > >><br /> > >> The converter works flawlessly when run from the command line. <br /> > The problem<br /> > >> is that the web version of the converter, which uses the same code as the<br /> > >> command-line version, does not reproduce the newlines properly, and thus,<br /> > >> the downloaded file does not have the newlines where they should be <br /> > -- that<br /> > >> is, there are no newlines in the downloaded file at all.<br /> > >><br /> > >> Just to give you an idea of what I'm doing...<br /> > >><br /> > >> The web version of the converter loads the file that needs to <br /> > be converted<br /> > >> into @converto, coverts the data, and then the following is passed to the<br /> > >> browser:<br /> > >><br /> > >> print "Content-type:text/html\n";<br /> > >> print "Content-Disposition:attachment;filename=convertedFile.txt\n \n";<br /> > >> print @converto;<br /> > >><br /> > >> Is there a way to have the newlines faithfully reproduced? I've tried<br /> > >> various Content-encodings (i.e. quoted-printable, base7, even binary) and<br /> > >> the results are always the same (no newlines reproduced). Attempts to <br /> > force<br /> > >> newlines with a for loop, i.e.:<br /> > >><br /> > >> foreach (@converto) { print "$_\n"; } # I've tried: <br /> > \n\r \n\n \n\r\n\r<br /> > >><br /> > >> Will produce random newlines, but the converted file remains "broken".<br /> > >><br /> > >> Any advice would be super-appreciated...<br /> > >><br /> > >> Thanks!<br /> > >><br /> > >> Todd<br /> > ><br /> > ><br /> > > if you're trying to put line breaks into html content that will <br /> > be displayed<br /> > > in a<br /> > > browser, try using "<br>". e.g.,<br /> > ><br /> > > foreach (@converto) { print "$_<br>"; } # browser line break<br /> > ><br /> > > _http://www.htmlhelp.com/reference/html40/alist.html_<br /> > > (http://www.htmlhelp.com/reference/html40/alist.html) has info on <br /> > html elements.<br /> > ><br /> > > hth -- bill walters<br /> > ><br /> > ><br /> > ><br /> > ><br /> > ><br /> > > ------------------------------------------------------------ ------------<br /> > ><br /> > > _______________________________________________<br /> > > ActivePerl mailing list<br /> > > ActivePerl@listserv.ActiveState.com<br /> > > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs<br /> ><br /> >There is also the <PLAINTEXT> tag that you can try. Put it at the very<br /> >top of the document and the rest of the document is interpreted as text,<br /> >not html. You can also try giving the downloaded file a .txt suffix.<br /> ><br /> >Tony<br /> ><br /> >--<br /> ><br /> >I always have coffee when I watch radar!<br /> >_______________________________________________<br /> >ActivePerl mailing list<br /> >ActivePerl@listserv.ActiveState.com<br /> >To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs<br /> <br /> _______________________________________________<br /> ActivePerl mailing list<br /> ActivePerl@listserv.ActiveState.com<br /> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs</p> </article> <article> <h2>Re: content-type woes and the evils of /n -- any advice?</h2><span>am 09.12.2006 01:41:19 von intertwingled</span> <p>If you have access to a Linux of FreeBSD box or you have Cygwin <br /> installed on your Windows box, you might want to try the diff or cmp <br /> commands to compare the two files. od -c might also come in handy.<br /> <br /> Tony<br /> <br /> _______________________________________________<br /> ActivePerl mailing list<br /> ActivePerl@listserv.ActiveState.com<br /> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs</p> </article> <article> <h2>Re: content-type woes and the evils of /n -- any advice?</h2><span>am 09.12.2006 03:37:20 von dbecoll</span> <p>Todd Morrison wrote:<br /> <br /> > Hello Everyone!<br /> > <br /> > I've written a file-converter that grabs what is essentially a CSV file,<br /> > and spews it out in a reformatted fashion. Each line of the "CSV" is<br /> > terminated by a newline, and must be reproduced in the conversion.<br /> > However, I've hit a wall.<br /> > <br /> > The converter works flawlessly when run from the command line. The<br /> > problem is that the web version of the converter, which uses the same<br /> > code as the command-line version, does not reproduce the newlines<br /> > properly, and thus, the downloaded file does not have the newlines where<br /> > they should be -- that is, there are no newlines in the downloaded file<br /> > at all.<br /> > <br /> > Just to give you an idea of what I'm doing...<br /> > <br /> > The web version of the converter loads the file that needs to be<br /> > converted into @converto, coverts the data, and then the following is<br /> > passed to the browser:<br /> > <br /> > print "Content-type:text/html\n";<br /> > print "Content-Disposition:attachment;filename=convertedFile.txt\n \n";<br /> > print @converto;<br /> <br /> Try:<br /> <br /> print "Content-type: text/plain\n\n";<br /> print @converto;<br /> <br /> If converto doesn't have newlines, add them as below with your foreach.<br /> <br /> > Is there a way to have the newlines faithfully reproduced? I've tried<br /> > various Content-encodings (i.e. quoted-printable, base7, even binary)<br /> > and the results are always the same (no newlines reproduced). Attempts<br /> > to force newlines with a for loop, i.e.:<br /> > <br /> > foreach (@converto) { print "$_\n"; } # I've tried: \n\r \n\n \n\r\n\r<br /> > <br /> > Will produce random newlines, but the converted file remains "broken".<br /> > <br /> > Any advice would be super-appreciated...<br /> _______________________________________________<br /> ActivePerl mailing list<br /> ActivePerl@listserv.ActiveState.com<br /> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs</p> </article> <article> <h2>RE: content-type woes and the evils of /n -- any advice?</h2><span>am 11.12.2006 14:35:22 von eroode</span> <p>-----Original Message-----<br /> From: activeperl-bounces@listserv.ActiveState.com<br /> [mailto:activeperl-bounces@listserv.ActiveState.com] On Behalf Of Todd<br /> Morrison<br /> Sent: Friday, December 08, 2006 7:26 PM<br /> To: activeperl@listserv.ActiveState.com<br /> Subject: Re: content-type woes and the evils of \n -- any advice?<br /> <br /> > I would like to thank everyone for their help... Mark, Bill, and<br /> Anthony. <br /> > I really do appreciate it! Such wonderful assistance, on a Friday no<br /> less!<br /> > <br /> > I have a feeling that my blabber-some e-mail was a bit vague.<br /> Essentially,<br /> > the web-version of the converter pushes a download through the<br /> browser, <br /> > and newlines must be reproduced in the downloaded file for use with a <br /> > third-party desktop application (which is very persnickety about<br /> placement<br /> > of newlines to the point of hair-pulling -- that and the file must be<br /> > purely text; no HTML allowed).<br /> <br /> Then why did you indicate that your output was HTML?<br /> <br /> > print "Content-type:text/html\n";<br /> > print "Content-Disposition:attachment;filename=convertedFile.txt\n \n";<br /> > print @converto;<br /> <br /> Your "Content-type" needs to reflect the kind of output your program is<br /> producing.<br /> <br /> Eric<br /> _______________________________________________<br /> ActivePerl mailing list<br /> ActivePerl@listserv.ActiveState.com<br /> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs</p> </article> <footer> <a href="/">Index</a> | <a href="/impressum.php">Impressum</a> | <a href="/datenschutz.php">Datenschutz</a> | <a href="https://www.xodox.de/">XODOX</a> </footer> </main> </body> </html>