Discussion:
binary vs text files
(too old to reply)
Paul Edwards
2019-12-14 21:48:14 UTC
Permalink
It seems that MSDOS has an "ioctl" call

http://www.ctyme.com/intr/rb-2821.htm
http://www.ctyme.com/intr/rb-2820.htm
bit 5

that allows an application to inform the
OS whether this is a binary or text file
that is being read/written.

Does Windows have something to distinguish
whether a file is text or binary?

Unix seems to have O_TEXT and O_BINARY
on the open() call, but I'm not sure if
this is Posix or not.

Thanks. Paul.
Kaz Kylheku
2019-12-14 21:57:54 UTC
Permalink
Post by Paul Edwards
Unix seems to have O_TEXT and O_BINARY
on the open() call, but I'm not sure if
this is Posix or not.
Might you be mistaking Cygwin for Unix? :)
Charlie Gibbs
2019-12-15 00:01:57 UTC
Permalink
Post by Paul Edwards
It seems that MSDOS has an "ioctl" call
http://www.ctyme.com/intr/rb-2821.htm
http://www.ctyme.com/intr/rb-2820.htm
bit 5
that allows an application to inform the
OS whether this is a binary or text file
that is being read/written.
Does Windows have something to distinguish
whether a file is text or binary?
Unix seems to have O_TEXT and O_BINARY
on the open() call, but I'm not sure if
this is Posix or not.
fopen(filename, "w") creates a text file.
fopen(filename, "wb") creates a binary file.

By the same token, you can use "r" and "rb" to open
an input file in text or binary mode respectively.
--
/~\ ***@kltpzyxm.invalid (Charlie Gibbs)
\ / I'm really at ac.dekanfrus if you read it the right way.
X Top-posted messages will probably be ignored. See RFC1855.
/ \ "Alexa, define 'bugging'."
Paul Edwards
2019-12-15 01:50:55 UTC
Permalink
Post by Charlie Gibbs
fopen(filename, "w") creates a text file.
fopen(filename, "wb") creates a binary file.
By the same token, you can use "r" and "rb" to open
an input file in text or binary mode respectively.
Yes, but how is fopen() meant to inform
the OS (Windows) that it is operating in
text or binary mode, to give the OS a
chance of doing something different, such
as converting a text file from ASCII to
EBCDIC, or stripping CR from a Unix
filesystem.

BFN. Paul.

Loading...