Escape Sequences in Literals

Escape Sequences in Literals

String and character literals provide an escape mechanism that allows express character codes that would otherwise not be allowed in the literal. An escape sequence consists of a backslash character () followed by one or more other characters. The same sequences are valid in both character and string literals.

The complete set of escape sequences is as follows:

Escape sequence meaning:

\ Denotes a backslash () character' Denotes a single-quote (') character" Denotes a double-quote (") character
 Denotes a line feed (LF) character
 Denotes a carriage return (CR) character	 Denotes a horizontal tab (HT) characterf Denotes a form feed (FF) character Denotes a backspace (BS) character Denotes a character code in the range 0 to 255. 

The in the above consists of one, two or three octal digits (‘0’ through ‘7’) which represent a number between 0 and 255 (decimal).


About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist