Menu
Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Python
Sending binary data over CGI
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Tim Roberts" data-source="post: 1753374"><p>Really? This is such a common problem that most Windows Python programmers</p><p>encounter it very early in their experiments.</p><p></p><p>The issue, of course, is that stdout is opened as a text file, not as a</p><p>binary file, and we all know that the LF to CR-LF conversion you describe</p><p>is part of the normal processing of a text file in Windows.</p><p></p><p>If you must send binary data through stdout, do this before you start to</p><p>write:</p><p></p><p> import os</p><p> import msvcrt</p><p> ...</p><p> msvcrt.setmode( stdout.fileno(), os.O_BINARY )</p></blockquote><p></p>
[QUOTE="Tim Roberts, post: 1753374"] 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 ) [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Python
Sending binary data over CGI
Top