What does #13#10 stand for, in Delphi code?

Cryptic strings like "#13#10" appear regularly within Delphi source code. These strings aren't random gibberish, however; they serve an essential purpose for text layout.

A control string is a sequence of one or more control characters, each of which consists of the # symbol followed by an unsigned integer constant from 0 to 255 (decimal or hexadecimal) and denotes the corresponding ASCII character.

When you want, for example, to assign a two-line string to a Caption property (of a TLabel control), you can use the following pseudocode:

Label1.Caption := 'First line' + #13#10 + 'Second line';

The "#13#10" part represents a carriage return + line feed combination. The "#13" is the ASCII equivalent of the CR (carriage return) value; #10 represents LF (line feed).

Two more interesting control characters include:

  • #0 - NULL character
  • #9 - (horizontal) TAB

Note: here's how to translate a virtual-key to ASCII code.

Delphi tips navigator:
» How to exchange Bitmap images between two TImageList components
« How to set the DataSource property to several db-aware controls in one call