Character Set
·
Language
supports à collection of characters à use in the source code.
·
Use
in the program for identifiers, literals, and other syntactical elements.
Divided into different categories,
including:
- Basic
Source Character Set
- Character
Literals and Escape Sequences
1. Basic Source Character Set
Used in C++ source code.
The basic character set is made up
of:
- Alphabetic
Characters:
- Lowercase
letters: a to z
- Uppercase
letters: A to Z
- Digits:
- 0
to 9 (used in numeric literals)
- Whitespace
Characters:
- Space
(' '), tab ('\t'), newline ('\n'), carriage return ('\r'), vertical tab
('\v'), and form feed ('\f').
- Punctuation
Characters:
- Operators
and Delimiters:
+, -, *, /, %, =, ++, --, <<, >>, &, |, ^, ~, !, ?, :
(conditional), ,, ;, [], {}, (), . (dot).
- Brackets
and Parentheses:
{, }, [, ], (, ) (used in the structure of C++ code, such as for arrays,
functions, etc.).
- Special
Characters:
- #,
\\, ', " (for comments, backslash, single and double quotes).
- Escape
sequences, such as \\, \', \", \n, etc., are used in strings and
character literals.
2. Character Literals and Escape
Sequences
Individual characters enclosed in
single quotes.
define variablesà to hold a single character.
- Character
Literal: A
single character enclosed in single quotes, e.g., 'A', 'b', '1', '%'.
- Escape
Sequences:
Special characters represented by a backslash followed by another
character, e.g.,:
- \n:
Newline (line break).
- \t:
Horizontal tab.
- \r:
Carriage return.
- \\:
Backslash.
- \':
Single quote (used in character literals).
- \":
Double quote (used in string literals).
- \0:
Null character (end of string).
- \b:
Backspace.
- \f:
Form feed (page break).
- \v:
Vertical tab.
- \uXXXX:
Unicode escape sequence (4 hexadecimal digits).
- \UXXXXXXXX:
Unicode escape sequence (8 hexadecimal digits).
--------------------------------------------------------------------------------------
0 Comments