DevKits

ASCII 18

Device Control 2 (DC2)

Control character

Legacy device control.

Common uses & context

Decimal 18 (0x12) is the Device Control 2 control character — one of the 33 non-printing codes in the C0 control block (0–31 plus DEL at 127). Control characters were designed to command teletype and terminal hardware rather than to represent visible glyphs, so DC2 produces no letter, digit, or symbol on screen. Its8-bit binary form is 00010010 and its octal value is 0022.

Legacy device control.

BecauseDC2 is invisible, it is easiest to work with by its numeric code. In most languages you can produce it with the escape or code-point form shown below, and detect it by comparing a byte against 18 (0x12). When it turns up unexpectedly in text — pasted from a terminal, a legacy file, or a binary blob — it is usually the cause of "invisible character" bugs that break parsing or comparisons.

All encodings at a glance

Decimal18
Hexadecimal0x12
Octal0022
Binary00010010
HTML numeric entity
URL encoding%12
UTF-8 bytes0x12

Code snippets

JavaScript

String.fromCharCode(18); // "DC2"
18.toString(16); // "12"

Python

chr(18)           # control char DC2
ord(chr(18))      # 18
hex(18)           # '0x12'

HTML

&#18;   <!-- numeric entity (no named entity for this character) -->

Programming notes

  • Detect it by numeric comparison: byte === 18 (0x12). It has no printable glyph to match on.
  • Control characters below 32 are stripped or rejected by many text validators — check for them when sanitizing user input.
  • In a hex dump DC2 shows as 12; in a "cat -v" style view it may appear as a caret sequence.

Frequently asked questions

What character is ASCII code 18?

ASCII code 18 is Device Control 2 (DC2), a non-printing control/whitespace character. In hexadecimal it is 0x12 and in binary 00010010. It has no visible glyph — it controls formatting or hardware instead of drawing a symbol.

What is 0x12 in ASCII?

Hexadecimal 0x12 equals decimal 18, which is theDevice Control 2 control character (DC2). To convert hex to ASCII yourself, read the two hex digits as a base-16 number (0x12 = 18) and look up that code point.

How do I write the character with code 18 in code?

In JavaScript use String.fromCharCode(18); in Python use chr(18); in HTML use the numeric entity &#18;. In a URL it is percent-encoded as %12, and in UTF-8 it is stored as the byte sequence 0x12.

Is ASCII 18 (DC2) printable?

No. DC2 (code 18) is a control character with no visible glyph. It instructs software or hardware rather than displaying a symbol, which is why it often appears as an invisible or replacement character when it leaks into ordinary text.

Nearby codes

Encode & convert this character