<!-- PDF page 74 -->

## Chapter 13 – The Character Set

The letters, digits, punctuation marks and so on that can appear in strings are called characters, and they make up the alphabet, or character set that the ZX Spectrum Next uses.

### CHR$ and CODE

As you will also see in *Appendix A*, there are *256* character locations, and each one is assigned a code between *0* and *255*. To convert between codes and characters, two functions exist: **CODE** and **CHR$**. **CODE** is applied to a string, and returns the code of the first character in the string (or **0** if the string is empty). **CHR$** is applied to a code, and returns the single character string that corresponds to that code. We started this paragraph by saying "character locations" and not simply "characters. As we will find out further below and in *Chapters 14*, *20* and *Appendix A*, some characters are non-printable and as a matter-of-fact perform special functions. The following little program prints out the entire *usable* character set:

```
10 FOR a=32 TO 255: PRINT CHR$ a;: NEXT a
```

At the top you can see a space, 15 symbols and punctuation marks, the ten digits, seven more symbols, the capital letters, six more symbols, the lower case letters and five more symbols. These are all (except £ and ©) taken from a widely-used set of characters known as *ASCII* (standing for American Standard Codes for Information Interchange); *ASCII* also assigns numeric codes to these characters, and these are the codes that the ZX Spectrum Next uses.

#### The graphics symbols

The rest of the characters are not part of *ASCII*, and are specific to the ZX Spectrum Next. First amongst them are a *space* and 15 patterns of black and white blobs. These are called the *graphics symbols* and can be used for drawing rudimentary pictures. You can enter these from the keyboard, using what is called *graphics mode*.

If you press **GRAPHICS** then the cursor will change to a flashing white/magenta. Now the keys for the digits **1** to **8** will give the graphics symbols: on their own they give the symbols drawn on the keys; and with either shift pressed they give the same symbol but inverted, i.e. black becomes white, and vice versa. Regardless of shifts, digit **9** takes you back to normal mode (blue cursor) and digit **0** is **DELETE**. Here are the sixteen graphics symbols:

| Symbol | Code | Key | Symbol | Code | Key |
|---|---|---|---|---|---|
|   | 128 | 8 | █ | 143 | Shift+8 |
| ▝ | 129 | 1 | ▙ | 142 | Shift+1 |
| ▘ | 130 | 2 | ▟ | 141 | Shift+2 |
| ▀ | 131 | 3 | ▄ | 140 | Shift+3 |
| ▗ | 132 | 4 | ▛ | 139 | Shift+4 |
| ▐ | 133 | 5 | ▌ | 138 | Shift+5 |
| ▚ | 134 | 6 | ▞ | 137 | Shift+6 |
| ▜ | 135 | 7 | ▖ | 136 | Shift+7 |

*Table 5 – Graphics Symbols*

