Normally, all of the characters in your literal strings (as well as your REXX script itself) are ascii characters. This means that they are printable characters such as the letters 'a' to 'z' (or 'A' to 'Z'), the digits '0' to '9', and various punctuation such as an exclamation mark, commas, question marks, etc (ie, most of the other keys labeled upon your computer keyboard) -- even a space or tab.

But sometimes, you may want to embed special characters into a literal string. In order to embed such a character, it may require you to enter a value that falls outside of the range of the ascii characters (and therefore does not have a key on your keyboard to easily enter it). You can't easily enter these values using a normal text editor (although some editors do allow you to press a special key combo to embed one of these special characters in your text. But some interpreters may get confused if you directly embed such a character as so. The most compatible way to specify a special character will be as described below).

When specifying one of these special characters, you can specify its value in hexadecimal or binary. Use whichever of those two numeric bases that you prefer. And you'll need to specify this character as its own literal string.


Hexadecimal

If you wish to express a character in base 16 (ie, hexadecimal), you specify the hexadecimal value for the character in quotes, and then put an x (or X) immediately after the closing quote.

The hexadecimal numbering system uses the digits 0 to 9, as well as the letters "a" to "f" (or "A" to "F"), inclusive. For example, here's how to express a character whose hexadecimal value is "A":

"a"x
As another example, here's a character whose value is 315 in hex (actually, this is a large enough value in hex, that 2 special characters will be embedded for it -- one character with a hex value of 03 and another character with a hex value of 15):
"315"x
For hex values, you can separate each "byte" by spaces. A "byte" is simply two hex digits, which is equivalent to one character. But you can put spaces only inbetween bytes. For example, here is a series of 3 hex bytes (3 characters) that comprise the value F003F7:
"F0 03 F7"x

Binary

If you wish to express a character in base 2 (ie, binary), you specify the binary value for the character in quotes, and then put a b (or B) immediately after the closing quote.

For example, here's how to express the value "11" (3 in decimal) as a binary value:

"11"b
As another example, here's the value 1000 (ie, decimal 8) in binary:
"1000"b
For binary values, you can separate each "byte" (8 binary digits) or "nibble" (4 binary digits) by spaces. But you can put spaces only inbetween bytes or nibbles. For example, here is a series of 3 binary nibbles that comprise the value 1015 in decimal:
"0011 1111 0111"x

Typical uses of special characters

Sometimes, you may want to embed a new line character in some literal string. Upon most systems, a new line character takes the form of the special character with a hexadecimal value of 0A (or a binary value of 1101). Here then is how you specify that special character in hexadecimal:

"0A"x
So, if you wanted to embed a new line character in the middle of a literal string, you could use the concatenation operator to create a longer literal string with this special character inserted where needed. Here's an example:
SAY "This is one line." || "0A"x || "This is another line."
Other special characters may include a carriage return ("0D"x), a formfeed ("0C"x), a nul character ("00"x), and even high ascii characters (ie, hexadecimal values over "7F"x) to embed special "graphics characters" in literal strings.

Note: If you're formatting a literal string to be written to some file (ie, stream) or the display, then it is better to let the LINEOUT() built-in function write out each line, rather than using special new line and/or carriage return characters embedded in your literal strings. This is because different operating systems use different combinations of new line and carriage return characters, and LINEOUT() takes this into consideration when it writes out a line. For example, the following two REXX instructions would be a preferable way to display those two lines that we used with SAY above:

err = LINEOUT(, "This is one line.")
err = LINEOUT(, "This is another line.")