Friday, April 20, 2007

I know i can count, but i'm not sure about my mac

So in a moment of boredom, i opened up my trusty text viewer, and had a look at some files. Namely a RTF, and a Text File.

First off, i now understand why programmers love plain text files so much. First off, there are no bytes wasted on headers. It's straight into the data, no messing and no playing.

So here is the test stub
#!/bin/bash

## Coursework mass compilation

cd ~/Desktop/OOTM

javac TerminalInput.java

javac Deck.java

javac Player.java

javac Game.java

javac CardGame.java

## Run the application

##java CardGame

This was a little bash script i wrote to help compile my coursework.
Not to remember the basics, each character is equal to a single byte, or 8 bits. FF is therefore equal to 255.

The plain text file is 8KB, with 204 characters. My maths tells me that should be equal to 204 bytes. But for some reason, my mac accounts another 1300 + bytes!!

Mean while the Rtf file is 4KB, with 561 bytes, which is the exact number of characters in the file. But wait you say, there are only 204 characters in the file. Correct, so whats the other junk ....
{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf420
{\fonttbl\f0\fswiss\fcharset77 Helvetica;}
{\colortbl;\red255\green255\blue255;}
\paperw11900\paperh16840\margl1440\margr1440\vieww9000\viewh8400\viewkind0
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural

\f0\fs24 \cf0


I only went through it briefly, but it appears to show the font types, and colors for the file.

But my question to the world is, why on earth is the text file twice the size, but yet still halve the number of bytes in the hex editor?

No comments: