First, the key terms.

Bit
One binary digit, conventionally zero or one.
Byte
A group of eight bits in modern systems.
Code point
A number identifying a Unicode character or component.

The idea, explained

Numbers stored in memory have an interpretation determined by a format. The same bytes can mean text, an image or machine instructions under different rules. Unicode assigns code points to characters, while UTF-8 encodes those code points as one or more bytes. Character count, byte count and visible-symbol count can differ. This matters for storage limits, truncation, validation and international language support.

STEP 1

Count combinations

One bit represents two states. Two bits represent four states: 00, 01, 10 and 11. Eight bits represent 256 possible patterns. The pattern’s meaning comes from an agreed format; bytes are not inherently text or numbers.

STEP 2

Choose an interpretation

An image decoder, text decoder and audio decoder interpret bytes differently. For text, Unicode identifies characters and UTF-8 specifies a byte encoding. A file can appear corrupted if it is decoded with assumptions different from those used when writing it.

STEP 3

Distinguish storage from appearance

Some visible symbols use multiple code points, and some code points use multiple UTF-8 bytes. Limiting a name field by raw bytes can unexpectedly reject or damage names. User-interface length limits and storage limits should be designed with this distinction in mind.

Follow a worked example.

The word “café” contains four letters, but its UTF-8 byte length is not necessarily four. A program that slices raw bytes at an arbitrary limit can break a multibyte character and display a replacement symbol.

Walk it through, one step at a time

  1. Represent the nonnegative integer 5 in binary as 101: four plus zero plus one.
  2. A single byte can store that pattern padded with leading zeroes: 00000101. Whether those bits mean the number 5 depends on the format.
  3. Now store text rather than that integer. The character “5” uses its text-encoding value, not the same raw representation as the integer five.

Where people get stuck

Do not assume that every visible character occupies one byte or one code point.

Now try it yourself.

Pause before opening each answer. Explain your reasoning in your own words.

1. Check the core idea

Can a field limited to 100 bytes always hold 100 characters?

Reveal the answer & reasoning

No. Encoding and the characters used determine byte length. Validation should distinguish byte limits from user-visible text length.

2. Apply what you learned

Are the integer 5 and the text character “5” always stored identically?

Reveal the answer & reasoning

No. They are different data types. Their byte representations depend on the numerical format and text encoding selected.