Escape Sequences

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Escape sequences

Saturday, June 1, 2024 12:40 AM

Common Escape Sequences in Dart Raw Strings


Backslash (\\): Represents a single backslash. Prefix with r to treat backslashes as regular characters.
var example = "This is a backslash: \\";
print(example); // Output: This is a backslash: \ var rawString = r"C:\Program Files\Dart";
print(rawString); // Output: C:\Program Files\Dart
Single quote (\'): Represents a single quote. Multiline Strings
Use triple quotes to create multiline strings.
var example = 'It\'s a nice day!';
print(example); // Output: It's a nice day! var multilineString = '''This is a
Double quote (\"): Represents a double quote. multiline string.''';
print(multilineString); // Output:
var example = "She said, \"Hello!\""; // This is a
print(example); // Output: She said, "Hello!" // multiline string.
Newline (\n): Represents a new line.
var example = "First line\nSecond line";
print(example); // Output:
// First line
// Second line
Carriage return (\r): Represents a carriage return.

var example = "First line\rSecond line";


print(example); // Output: Second lineine
Tab (\t): Represents a tab.
var example = "Column1\tColumn2";
print(example); // Output: Column1 Column2
Backspace (\b): Represents a backspace.
var example = "Hello\b World";
print(example); // Output: Hell World
Unicode (\uXXXX): Represents a Unicode character.
var example = "\u2665"; // Heart symbol
print(example); // Output: ♥

Unicode (variable length) (\u{X...X}): Represents a variable


length Unicode character.rt
var example = "\u{1F600}"; // Smiley face
print(example); // Output:

Dart Page 1

You might also like