Function: set-binary-mode
set-binary-mode is a function defined in fileio.c.
Signature
(set-binary-mode STREAM MODE)
Documentation
Switch STREAM to binary I/O mode or text I/O mode.
STREAM can be one of the symbols stdin, stdout, or stderr.
If MODE is non-nil, switch STREAM to binary mode, otherwise switch
it to text mode.
As a side effect, this function flushes any pending STREAM's data.
Value is the previous value of STREAM's I/O mode, nil for text mode, non-nil for binary mode.
On MS-Windows and MS-DOS, binary mode is needed to read or write
arbitrary binary data, and for disabling translation between CR-LF
pairs and a single newline character. Examples include generation
of text files with Unix-style end-of-line format using princ in
batch mode, with standard output redirected to a file.
On Posix systems, this function always returns non-nil, and has no effect except for flushing STREAM's data.
Probably introduced at or before Emacs version 25.1.
Source Code
// Defined in /usr/src/emacs/src/fileio.c
{
FILE *fp = NULL;
int binmode;
CHECK_SYMBOL (stream);
if (EQ (stream, Qstdin))
fp = stdin;
else if (EQ (stream, Qstdout))
fp = stdout;
else if (EQ (stream, Qstderr))
fp = stderr;
else
xsignal2 (Qerror, build_string ("unsupported stream"), stream);
binmode = NILP (mode) ? O_TEXT : O_BINARY;
if (fp != stdin)
fflush (fp);
return (set_binary_mode (fileno (fp), binmode) == O_BINARY) ? Qt : Qnil;
}