This topic covers how text characters are stored as bytes in computer files, comparing plain-text editors with rich-text editors that include hidden formatting data.
What I'm going to do is right click, say new, and create a new text document, and we'll call this Characters, because we're going to be exploring characters with this text document. I'll right click on here and go into properties just to see how big it is. It is 0 bytes, so the file itself really isn't taking up any size at this point in time.
So what I'll do is open this up and just hit A. Can you guess approximately how big this is going to be? I'll give you a hint: ASCII just uses seven bits, so it's probably going to be close to a byte. I'm going to hit save here, and then I'm going to right click on here and go to properties, and notice that it is now one byte.
In fact, I can do this again. Let's type in a B here and hit save now, and then what does our properties say? If I go to properties, now this is two bytes. So it's growing by a byte for every character.
If you notice here, this is UTF-8. So if I pull up a web browser and I type in UTF-8 and we'll hit enter, this is the wiki site, and this is a character encoding, and it extends ASCII. So it's based off of ASCII — at least the beginning part of this is ASCII — and it can be anywhere from 1 to 4 bytes, so it's variable length. One byte just represents the ASCII characters, and then we can extend beyond that. So it makes sense that it's storing eight bytes every time we add a character to it, because it's using this character set, this UTF-8.
What I want to do is generate much more traffic to this, so I'm going to look for lorem ipsum, which is going to bring up something I can generate lots of characters in. I'm going to copy this and I'll paste it in here to get a lot of this. In fact, let me copy this and paste and get a lot of characters here.
So now we've got 8,140 characters. Can you guess how many bytes this is going to be? I'm going to hit save right here, we're going to look at the properties of this file, and now notice we have 8,140 bytes, which matches up exactly with the characters. So we can see how there's this one-for-one when we're using Notepad.
I want to show you a different program though. What I'll do is create a document — I'm going to open up WordPad for this. Here's my WordPad document, and I'm going to save this, so I just saved this Characters 2 here.
The first thing I'll do is look at the properties, and notice that this WordPad document is 193 bytes now. So immediately it's much bigger. Now I'll open up this program here and let's take a look at this. I have a lot more options: I can insert pictures to it, I can change the format.
Let me just type in an A. So originally, let's take a look at this one more time: it's 193 bytes. I've got an A on here, I'm going to save this now and let's see how it changes. We'll look at the properties again and it's 195 bytes, so it added two bytes with just that single character added to it. Let's add another one here and see what the property changes to — so now it's 196, so I added another byte to it. So let's add another character and we'll save it and look at the properties: now 196 to 197. So it's adding about a byte per character here.
We're at 197 bytes, but we also have the formatting that we can do here. So let's take the B here and let's make it bold, maybe change the font, we're going to do an underline, maybe strikethrough. So we're changing some aspects to just one character on here. I'm going to save this. We were at 197 — let's take a look at the properties now. 279. So it immediately jumped up quite a bit.
That's because what happens is, on the back end here we're just seeing the ABC and the B is being formatted in this way, but there's a markup language in the backside of this, and the backside of it says, make this bold and make this underline and make this strikethrough. So it's giving this extra instructions with this markup language, and those are actually extra characters that are not visible to us but are seen on the back end to the program. So now we have 279 bytes, because we're doing some formatting to it.
That's one of the reasons why I like to use Notepad a lot: because Notepad doesn't bring a lot of the fluff in it, so you can copy and paste text in clear text, versus this is going to have some formatting to it.
Just to show you what I mean by that, if I hit copy over here and open it up, notice it removes the formatting. So I can hit copy here and then paste it back into here, and now there's no longer formatting. So Notepad can be used to kind of filter out some of the formatting if you're copying things.
TechKnowSurge builds IT and cybersecurity professionals through hands-on, concept-first training built around real understanding — not memorization. Free interactive tools, structured programs, and 25+ years of real-world experience, all in one place.
Explore free tools and programs →