Home

chars

Chars, short for characters, are elemental units of text used in computer processing. A char represents a single symbol from a character set, such as a letter, digit, or punctuation, and is often the basic building block of strings. The precise representation of a char depends on the programming language and the encoding in use; some treat a char as a simple code point, others as a small container for a byte or code unit.

In C and C++, a char is typically one byte wide and can hold an 8-bit value

In Python, there is no distinct char type; strings are sequences of Unicode code points. Accessing an

When stored or transmitted, chars are encoded into a byte sequence according to an encoding such as

corresponding
to
an
ASCII
character
or
part
of
a
multibyte
encoding.
C
programmers
commonly
store
text
in
char
arrays.
Since
Unicode,
there
are
related
types
like
wchar_t,
char16_t,
and
char32_t
for
wider
encodings.
In
Java,
a
char
is
a
16-bit
unsigned
value
representing
a
UTF-16
code
unit.
A
single
visual
character
outside
the
BMP
may
require
two
chars
(a
surrogate
pair)
to
represent.
element
yields
a
one-character
string
rather
than
a
separate
char
type,
and
the
internal
encoding
(UTF-8,
UTF-16,
or
UTF-32)
is
abstracted
away
from
the
user.
UTF-8,
UTF-16,
or
ASCII.
Understanding
the
distinction
between
code
points
and
code
units
matters
for
processing
non-ASCII
characters
and
for
correct
indexing,
normalization,
and
string
manipulation.