diff between binary & text file

Programming, for all ages and all languages.
Post Reply
neopro

diff between binary & text file

Post by neopro »

hi all,

what is the diff between binary & text file ... in sense to size of the file ...

thanks in advance
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:diff between binary & text file

Post by Candy »

Neo Pro wrote:
hi all,

what is the diff between binary & text file ... in sense to size of the file ...

thanks in advance
with binary files you try to read it as a binary, with text files you try to read it as text

There is no fscking difference

The only place where this is a concern is at the places of very awkward computers (with odd bit sizes) where text files can be represented in 4*7-bits, for a total of 28 (example machine has 28 bit registers), and the binaries must preserve all bits so it can only fit 7*8 bits in 2 28-bits registers. These machines are long since gone, except for some very shut-off places where I hope you never will go.

It's also in use in linux-mac-windows cooperative land, where files are copied and newlines are adjusted. Adjusting newlines in a file where the newline characters are not newlines, it really bad. So, they call them binary, and adjust it in all the others.

Obviously, everybody should just conform to one standard, where I vote for either the mac or the unix one. Windows spills too much (a char-size per newline). In the current world, the main place you will find exchange problems is on windows, since they put the default ftp on text-by-default, which totally wrecks all binaries you up/download. Unix does binary by default, and text for known file formats, on up/download, using most up/downloaders.

Technical stuff:
Newlines on unix (and possibly macos 10) are 0x0a. Newlines on older macs (and again, possibly macos 10) are 0x0d. Newlines on Windows are 0x0d 0x0a, and some people swap it to 0x0a 0x0d (which they shouldn't but do anyway). Filter out these newlines and replace them with your preferred newlines in text files, and you're all set. When transferring over ftp, I believe the network-based transmission must be the unix one.
Post Reply