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
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
top of the document and the rest of the document is interpreted as text,
not html. You can also try giving the downloaded file a .txt suffix.
Tony
--
I always have coffee when I watch radar!
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: content-type woes and the evils of /n -- any advice?
am 09.12.2006 01:25:50 von Todd Morrison
I would like to thank everyone for their help... Mark, Bill, and Anthony.
I really do appreciate it! Such wonderful assistance, on a Friday no less!
I have a feeling that my blabber-some e-mail was a bit vague. Essentially,
the web-version of the converter pushes a download through the browser, and
newlines must be reproduced in the downloaded file for use with a
third-party desktop application (which is very persnickety about placement
of newlines to the point of hair-pulling -- that and the file must be
purely text; no HTML allowed).
When I input the source file ("file to be converted") into the command-line
converter it produces the converted file, which is 1.01KB in size. The web
version of the converter produces a 1.00KB file, which the third-party
application refuses to open. I've done a line-by-line comparison of the the
converted files (a simple $a eq $b test), and Perl reports that both files
are identical, yet the operating system reports a 1 byte difference. This
difference is increased if the source file is larger, of course. And of
course, this difference is being sniffed out by the third-party app which
refuses to play nice.
Again, thanks for your help, gentlemen! If you have any further ideas
(sledgehammer suggestions are welcomed), I'd love to read about them.
Have a great night!
Todd
At 07:00 PM 08/12/2006, Anthony R. Nemmer wrote:
>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
>top of the document and the rest of the document is interpreted as text,
>not html. You can also try giving the downloaded file a .txt suffix.
>
>Tony
>
>--
>
>I always have coffee when I watch radar!
>_______________________________________________
>ActivePerl mailing list
>ActivePerl@listserv.ActiveState.com
>To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: content-type woes and the evils of /n -- any advice?
am 09.12.2006 01:41:19 von intertwingled
If you have access to a Linux of FreeBSD box or you have Cygwin
installed on your Windows box, you might want to try the diff or cmp
commands to compare the two files. od -c might also come in handy.
Tony
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: content-type woes and the evils of /n -- any advice?
am 09.12.2006 03:37:20 von dbecoll
Todd Morrison wrote:
> 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;
Try:
print "Content-type: text/plain\n\n";
print @converto;
If converto doesn't have newlines, add them as below with your foreach.
> 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...
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: content-type woes and the evils of /n -- any advice?
am 11.12.2006 14:35:22 von eroode
-----Original Message-----
From: activeperl-bounces@listserv.ActiveState.com
[mailto:activeperl-bounces@listserv.ActiveState.com] On Behalf Of Todd
Morrison
Sent: Friday, December 08, 2006 7:26 PM
To: activeperl@listserv.ActiveState.com
Subject: Re: content-type woes and the evils of \n -- any advice?
> I would like to thank everyone for their help... Mark, Bill, and
Anthony.
> I really do appreciate it! Such wonderful assistance, on a Friday no
less!
>
> I have a feeling that my blabber-some e-mail was a bit vague.
Essentially,
> the web-version of the converter pushes a download through the
browser,
> and newlines must be reproduced in the downloaded file for use with a
> third-party desktop application (which is very persnickety about
placement
> of newlines to the point of hair-pulling -- that and the file must be
> purely text; no HTML allowed).
Then why did you indicate that your output was HTML?
> print "Content-type:text/html\n";
> print "Content-Disposition:attachment;filename=convertedFile.txt\n \n";
> print @converto;
Your "Content-type" needs to reflect the kind of output your program is
producing.
Eric
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs