Char: Difference between revisions
From Coderwiki
More actions
m replace link to 'character encoding' with link to 'character set' |
reference Collection in 'making up a string' section |
||
| Line 8: | Line 8: | ||
== Making up a [[string]] == | == Making up a [[string]] == | ||
When multiple <code>char</code> values are collected in an [[array]] or [[list]], they form a ''sequence of characters'' known as a [[string]]. | When multiple <code>char</code> values are collected in an [[array]] or [[list]] (or other [[collection]]), they form a ''sequence of characters'' known as a [[string]]. | ||
Latest revision as of 07:52, 13 August 2025
The char (or character) data type generally stores a single character, represented by a certain character set.
Size of a char
edit edit sourceChars are usually between 8 bits, but in some languages, are larger:
- 8-bit chars generally only store regular ASCII characters, or individual bytes of a UTF-8 unicode character (this is the case in the C programming language).
- Other languages such as Rust instead allow a
charto store any unicode character. In Rust, thechardata type has a size of 4 bytes, or 32 bits.
Making up a string
edit edit sourceWhen multiple char values are collected in an array or list (or other collection), they form a sequence of characters known as a string.