Menu

Character Sets

Bits per Character and Character Capacity

Every character in a character set needs its own binary code, and the number of bits per character decides how many different codes are possible. If each code is n bits long, there are 2 to the power of n different bit patterns, so the set can hold up to 2 to the power of n characters. For example, 3 bits give 2 to the power of 3 = 8 codes, from 000 to 111. Each extra bit doubles the number of codes: 4 bits give 16, 5 bits give 32, and so on. The result is the number of unique codes available, not the largest code value.

A tree splits into 0 and 1 at each level: 1 bit gives 2 patterns, 2 bits give 4 and 3 bits give 8, from 000 to 111. Each extra bit doubles the count.

Bits per characterUnique codes available
24
38
416
8256
124,096
1665,536

Finding the minimum number of bits

To find the minimum number of bits for a required number of characters, find the smallest n where 2 to the power of n is at least that number. Imagine a language-learning app needs 300 different characters for its on-screen keyboard. Using 8 bits gives 256 codes, which is not enough. Using 9 bits gives 512 codes, which is enough, so the minimum is 9 bits per character. The spare codes could be assigned to new characters later.

More bits means bigger text files

Increasing the bits per character increases the number of characters the set can represent, but every stored character now uses more bits, so the text file grows. A 180-character museum caption stored at 7 bits per character takes 180 × 7 = 1,260 bits. The same 180 characters stored at 12 bits per character take 180 × 12 = 2,160 bits. Text file size therefore increases with both the number of characters stored and how many bits each stored character uses.

Practise this