How do I return binary data from a python CGI called from CGIHTTPServer?
Marcin 'Qrczak' Kowalczyk
qrczak at knm.org.pl
Wed Jun 6 14:52:13 EDT 2001
Tue, 5 Jun 2001 16:11:57 -0400, D-Man <dsh8290 at rit.edu> pisze:
> In MS-DOS terminals ctrl-z is used to indicate that you want to close
> the input stream (EOF). On Unix terminals it is ctrl-d instead. I
> think that the problem must be the sub-process thinks it is writing to
> a tty rather than a regular file, and thus is closing the output when
> you try and write ctrl-z.
Ctrl-z in DOS is not fully analogous to Ctrl-d in Unix. Text files
are usually assumed to end if Ctrl-z is encountered - it's not only
for terminals.
This silliness comes from CP/M which did not store file sizes exactly
but rounded up to the block size, so applications had to agree on a
convention for ending text files at an arbitrary point. Old editors
often put a single Ctrl-z at end of file, and for example appending
to files in Turbo Pascal checks for possible Ctrl-z in the last couple
of bytes in the file and overwrites it if necessary.
Handling Ctrl-z applies to text files like newline conversion, except
that it's hardly ever output now. Since C was invented together
with Unix, C on other platforms translates newline markers to the
C & Unix convention, and many other languages picked this idea too,
because it's simpler to uniformly work on a distinguished constant
character for line ending (and they can often use the C library to
do the actual work)...
--
__("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/
\__/
^^ SYGNATURA ZASTĘPCZA
QRCZAK
More information about the Python-list
mailing list