Unicode scalar value
A Unicode scalar value is a code-point value from U+0000 to U+10FFFF outside the surrogate range U+D800 to U+DFFF.
Range: Scalar values include assigned characters, unassigned code points and noncharacters, but exclude surrogates. Membership in this range does not mean that a value is assigned to a character or permitted by a particular filename or interchange profile. [1]
Representation: UTF-8 uses one to four octets per scalar value. UTF-16 uses one code unit for a non-surrogate value in the Basic Multilingual Plane and a surrogate pair for a supplementary value. U+1F600 is one scalar value, four UTF-8 bytes and two UTF-16 code units; either half of its pair alone is not a scalar value. [1] [2]
Text units: U+0065 followed by U+0301 contains two scalar values but one default extended grapheme cluster. Counting scalar values therefore differs from both storage-byte budgeting and user-facing text segmentation. Validate input before counting: replacement decoding can conceal distinctions between malformed byte sequences. [3] [2]
Relations
- related
- UTF-32, Character encoding, UTF-8, Grapheme cluster
Limitations
- Scalar validity does not establish normalization, filename equality or successful recovery.
Citations
- Unicode 17.0: chapter 3, section 3.9, D76-D79 and UTF-16
- RFC 3629: UTF-8 validity and malformed input
- Unicode Standard Annex 29 revision 47: grapheme cluster boundaries
Further reading
Sources & caveats
- Source-reviewed definition; constructed runtime examples are separate from the article's earlier filesystem observations.