Principle:ClickHouse ClickHouse Unicode Character Width
| Knowledge Sources | |
|---|---|
| Domains | Unicode, Text_Processing |
| Last Updated | 2026-02-08 00:00 GMT |
Overview
A principle for determining the visual display width of Unicode characters in fixed-width contexts such as terminals and text-based interfaces.
Description
Unicode Character Width is a fundamental concept in text rendering that addresses the fact that not all Unicode characters occupy the same amount of horizontal space. While most Latin characters are single-width (taking one column), East Asian characters (CJK), many emojis, and fullwidth forms are double-width (taking two columns). Additionally, combining characters and control characters have zero width, and some characters have ambiguous width depending on context.
This principle involves:
- Classifying characters according to Unicode East Asian Width properties
- Handling combining marks that modify preceding characters
- Managing emoji width calculations (including emoji that were widened in Unicode 9)
- Distinguishing between printable and non-printable characters
- Supporting private use and unassigned character ranges
Usage
Use this principle when:
- Implementing terminal emulators or text-based user interfaces
- Calculating cursor positions in text editors with Unicode support
- Aligning text in columns with mixed-width characters
- Determining string length for display purposes (distinct from byte or character count)
- Supporting internationalization with proper CJK and emoji rendering
Theoretical Basis
The principle is based on:
Unicode East Asian Width Property: The Unicode Standard defines the East Asian Width property (UAX #11) which categorizes characters as:
- Narrow (N) - Takes one column
- Wide (W) - Takes two columns
- Fullwidth (F) - Takes two columns
- Halfwidth (H) - Takes one column
- Ambiguous (A) - Width depends on context
- Neutral (Not East Asian) - Depends on script
Zero-Width Characters: Combining marks, zero-width joiners, and control characters that don't advance the cursor position.
Terminal Display Model: Text terminals traditionally use a fixed-width grid where each cell can display one character. Wide characters occupy two adjacent cells.
Emoji Width Evolution: Some emoji characters had their width changed from 1 to 2 in Unicode 9.0, requiring special handling for version compatibility.