Sending binary data over CGI
Walter Huf
hufman at cobalty.com
Thu Mar 4 18:07:10 EST 2004
Tim Roberts <timr at probo.com> wrote in
news:onod401p4rjbe9kuu10q6518l93ds7rks3 at 4ax.com:
>
> Really? This is such a common problem that most Windows Python
> programmers encounter it very early in their experiments.
>
> The issue, of course, is that stdout is opened as a text file, not as
> a binary file, and we all know that the LF to CR-LF conversion you
> describe is part of the normal processing of a text file in Windows.
>
> If you must send binary data through stdout, do this before you start
> to write:
>
> import os
> import msvcrt
> ...
> msvcrt.setmode( stdout.fileno(), os.O_BINARY )
Awesome, thanks! I'm quite new at Python. I've done a lot in Visual Basic,
and even written a couple cgiprogs in basic, but my server on the
internet(http://hufman.cobalty.com) is a linux server, and, Micro$oft being
Micro$oft, there is no visual basic compiler or interpreter for linux. I
started learning Python last Sunday, so I wouldn't know anything about the
conversions. Well, I knew about the newline conversions, I think, but I
didn't know how to get around it. I couldn't find anything about it in the
help. Thank you though!
--Walter Huf--
hufman at cobalty.com
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
More information about the Python-list
mailing list