What it does
- Properties and full case mapping (final sigma, Turkish and Lithuanian as options)
- NFC, NFD, NFKC and NFKD, also in chunks
- Graphemes, words and sentences (UAX 29), line breaking (UAX 14)
- DUCET collation (UTS 10) with per-language tailoring
- IDNA (UTS 46), Punycode and confusables (UTS 39)
- Bidirectional algorithm (UAX 9) up to L2
- 100% conformance with the official test files, on GCC and MSVC
- Every capability included in the SDK, with no option to set
Measured
- Release, i7-6700, GCC 15.2 / MSVC 19.51. <code>Properties()</code> for one code point: 2.6 ns and 2.2 ns (target 5 ns)
- NFC check on ASCII: 39.5 and 43.9 GB/s. NFC on text already in NFC: 903 and 782 MB/s
- Linked tables (GCC): 378.1 K for the whole module (target 400 K), 97.0 K for properties only (target 100 K). The code adds about 185 K
Known limits
- Collation from the root (DUCET) only, without CLDR tailorings
- Line breaking without a dictionary: Thai, Lao, Khmer and Burmese break only at spaces
Ethereal::Text · Tier 1
Everything that requires knowing what each character is: the properties, normalization (NFC/NFD/NFKC/NFKD), full case mapping, graphemes, words and sentences, line breaking, column width, truncating without breaking an emoji, collation (sorting the way people expect), internationalized domain names (IDNA, Punycode), confusables and bidirectional text. Encoding handles the rest (transcoding, validation, base64): whoever only wants that does not link a Unicode table.
Unicode 18.0.0, pinned (kUnicodeMajor/Minor/Update, UnicodeVersion()). The tables are generated from the UCD by tools/unicode_gen/gen_text.py and live in the repository (src/cpp/text/generated/): building requires neither the UCD nor Python, and changing versions is download_data.sh + the generator + reviewing the diff. The generator checks what the format assumes (and stops if a new version breaks it). See "The decisions".
No dynamic memory on any path. The caller provides the space (std::span), receives the required size in *pWritten (also with eBufferTooSmall), and whatever needs a work area (collation, skeletons, line breaking, bidi) works on the stack or in an area the caller provides. Each test file checks this with ETL_EXPECT_NO_ALLOC.
#include <ethereal/cpp/text/text_inc.hpp>
namespace X = Ethereal::Text;
char buf[ 256 ];
std::size_t n = 0;
X::Normalize( X::ENormalForm::eNFC, sInput, buf, &n ); // "e" + U+0301 -> "é"
bool bEqual = X::CaseInsensitiveEquals( "STRASSE", "straße" ); // full case folding: true
std::size_t nChars = X::CountGraphemes( sEmoji ); // the 7-code-point family counts as 1
std::size_t uEnd = X::TruncateToWidth( sName, 20 ); // never breaks a grapheme
int r = X::Compare( "file9", "file10", { .bNumeric = true } ); // < 0: by value
X::ToAscii( "München.de", buf, &n ); // "xn--mnchen-3ya.de"
bool bFake = X::AreConfusable( "paypal", "pаypal" ); // Cyrillic 'а': true---
Capabilities and options
Each capability with large tables lives in its own source and behind a CMake option (all enabled by default), which also defines the public macro ETL_TEXT_<CAPABILITY>.
| Option (CMake) | Macro | What it brings | Requires |
|---|---|---|---|
ETHEREAL_TEXT | ETL_TEXT | the properties (category, bidi, line break, East Asian width, GCB/WB/SB, InCB, script, combining class, numeric values, the Age, names) and case (lowercase, uppercase, case folding, CaseInsensitiveEquals) | nothing |
ETHEREAL_TEXT_NORMALIZATION | ETL_TEXT_NORMALIZATION | Normalize, IsNormalized, CNormalizer (in chunks) | nothing |
ETHEREAL_TEXT_SEGMENTATION | ETL_TEXT_SEGMENTATION | graphemes, words, sentences, ToTitle, line breaking, width, truncation and word wrap. And the Console switches to using the Text width | nothing |
ETHEREAL_TEXT_COLLATION | ETL_TEXT_COLLATION | SortKey, Compare, CCollationTailoring | normalization |
ETHEREAL_TEXT_IDN | ETL_TEXT_IDN | ToAscii, ToUnicode, Punycode, Skeleton, AreConfusable | normalization |
ETHEREAL_TEXT_BIDI | ETL_TEXT_BIDI | BidiLevels, BidiReorder, BidiToVisual, MirroredGlyph, BidiLineEnd | nothing |
CMake rejects, with the reason, collation or IDN without normalization. text_inc.hpp declares everything: calling a disabled capability is a link error. The exception is ToTitle, which without segmentation exists and returns eNotSupported.
---
Conformance: the official files, in full
Nothing here is a sample: each test reads the entire Unicode file (in third_party/unicode/18.0.0) with a reader written in the tests, independent of the generator.
| Capability | Against | Cases | Result |
|---|---|---|---|
| Properties | UnicodeData and the UCD derived files | all 1,114,112 code points, every field | ✅ all equal |
| Age | DerivedAge | all 1,114,112 code points | ✅ all equal (text.age) |
| Normalization | NormalizationTest | 20,171 lines × 4 forms, and Part1 (each code point not listed is its own form) | ✅ 100%. IsNormalized agrees on all of them. CNormalizer split at every byte (2,242,568 splits) gives the same as in one go. 1,600 segments of 20 to 400 marks through the slow path against an oracle |
| Case | UnicodeData, SpecialCasing, CaseFolding | every code point, simple and full | ✅ And the context rules of Table 3-17 (final sigma, Lithuanian, Turkish), with cases that trigger them and cases that do not |
| Graphemes | GraphemeBreakTest | 853 | ✅ 100%, through five paths: the forward iterator, backward from the end, IsBoundary at every byte, NextBoundary/PrevBoundary at every byte, Seek + Next/Prev |
| Words | WordBreakTest | 1,944 | ✅ 100%, the same five |
| Sentences | SentenceBreakTest | 512 | ✅ 100%, the same five. And 18,000 random texts (invalid bytes included) in which the forward state machine and the backward local decision (two implementations) give the same result |
| Line breaking | LineBreakTest | 19,346 | ✅ 100%, and the mandatory breaks exactly after BK, CR (without LF), LF, NL and at the end |
| Width | EastAsianWidth and the categories | every code point | ✅ the rules below |
| Collation | CollationTest_NON_IGNORABLE and _SHIFTED | 212,036 each | ✅ the key of each line equal, byte for byte, to the one in the file's comment. The lines in order. And Compare with the sign of the keys' memcmp on each consecutive pair (and on 30,000 random pairs, with all options) |
| IDNA | IdnaTestV2 | 6,394 × 3 (toUnicode, toAsciiN, toAsciiT) | ✅ the result and the exact set of error codes of each line |
| Confusables | confusables.txt | 6,712 | ✅ each source is confusable with its prototype |
| Bidi | BidiTest | 770,241 (the classes, in each requested direction) | ✅ levels and visual order |
| Bidi | BidiCharacterTest | 91,707 (real code points, brackets) | ✅ paragraph level, levels and visual order |
The only lines left out are those with lone surrogates (U+D800..DFFF): 30 in each collation file and 2 in the IDNA one. They cannot be written in UTF-8, which is what these functions read. The collation order is checked across the remaining lines (it is transitive).
---
The cost
Measured by ethereal_text_measurements (and text_properties) in Release, on an i7-6700 (3.4 GHz), the best of several passes. GCC 15.2 on WSL, MSVC 19.51 on Windows.
| Operation | GCC | MSVC | Spec target |
|---|---|---|---|
Properties() of a code point | 2.6 ns | 2.2 ns | < 5 ns ✅ |
| NFC check, ASCII | 39.5 GB/s | 43.9 GB/s | > 10 GB/s ✅ |
| NFC check, mixed text already in NFC | 865 MB/s | 811 MB/s | |
| NFC of text already in NFC | 903 MB/s | 782 MB/s | > 500 MB/s ✅ |
| NFC of text in NFD (work) | 197 MB/s | 166 MB/s | > 100 MB/s ✅ |
| NFD of text in NFC (work) | 138 MB/s | 163 MB/s | > 100 MB/s ✅ |
| NFKC of text in NFD | 186 MB/s | 159 MB/s | > 100 MB/s ✅ |
CaseFold / ToUpper | 338 / 315 MB/s | 239 / 221 MB/s | |
graphemes (CountGraphemes) | 111 MB/s | 98 MB/s | |
| words, forward / backward | 113 / 30 MB/s | 69 / 20 MB/s | |
| line break opportunities | 57 MB/s | 23 MB/s | |
StringWidth | 108 MB/s | 66 MB/s | |
SortKey (words of ~12 bytes) | 310 ns | 363 ns | |
Compare | 109 ns | 101 ns | |
ToAscii (one name) | 686 ns | 856 ns | |
BidiLevels (mixed text) | 28 MB/s | 28 MB/s |
SortKey generates the collation elements once and builds the keys for all levels from them (up to 512 elements. A longer text generates them again per level, streaming). Before, it was 885 ns per word on GCC. The LongKeysAgreeWithCompare test covers both paths.
---
The size
The linked cost of each capability (what the linker pulls into a program that uses it), measured by tools/text_sizes/measure.sh (GCC, Release, loadable sections):
| Capability | Code | Tables |
|---|---|---|
| properties | 2.2 K | 66.2 K |
| case | 10.9 K | 24.2 K |
| normalization | 74.0 K | 95.9 K |
| segmentation | 35.0 K | 66.3 K |
| line breaking and width | 49.8 K | 66.3 K |
| collation | 91.6 K | 281.5 K |
| IDNA | 105.3 K | 198.9 K |
| confusables | 81.1 K | 220.3 K |
| bidi | 15.5 K | 71.8 K |
| everything | 184.7 K | 371.6 K |
And per option configuration (the sum of the Text objects each one builds. tools/text_sizes/flags.sh configures, builds and runs the tests of each one):
| Configuration | Code | Tables |
|---|---|---|
ETHEREAL_TEXT=OFF | nothing | nothing |
| properties only (and case) | 13.6 K | 90.5 K |
| + segmentation | 61.7 K | 90.7 K |
| + normalization | 86.3 K | 186.4 K |
| + normalization and collation | 99.6 K | 300.5 K |
| + normalization and IDNA | 107.3 K | 252.0 K |
| + bidi | 26.1 K | 96.0 K |
| everything | 181.3 K | 371.7 K |
The spec targets: the whole module 371.6 K < 400 K ✅. Properties only 90.5 K < 100 K ✅.
**The age (Age, 2026-10-16, AI-01 stage 1).** The version in which each code point entered Unicode lives in the upper bits of each value of the properties trie, above the record index (which uses 11 bits): a single lookup, at the same cost as Properties(), and 5.5 K more in the trie, against 21.5 K for a separate trie. By the sum of the objects (GCC 15.2, Release), the tables of the properties-only configuration went from 91.0 K to 97.0 K (< 100 K ✅) and those of the whole module from 372.2 K to 378.1 K (< 400 K ✅). The tables above predate the age. The simple case orbit (SimpleCaseOrbitNext, for Regex (?i)) is a separate source: 456 bytes of table, and it is only pulled in by whoever calls it.
**The lowercase of a code point without context (LowerFull, 2026-10-18, AI-01 stage 3).** The unconditional full mapping of a code point (SpecialCasing without the conditions, otherwise UnicodeData), without final sigma and without a language rule: it is Rust's char::to_lowercase, which the Hugging Face Lowercase applies character by character. It uses the same case table, with no new table. Checked on every code point in text.case, and in the C layer (ETLC_TextLowerFull).
---
The decisions, and the declared deviations from the spec
The types. The spec writes SStringView, SStringSpanOut and EStatus. Here they are std::string_view, std::span< char > (+ std::size_t * pWritten) and ETextStatus. And "consumes IAllocator": nothing allocates memory, and so there is nothing to consume.
Rules that only the Unicode 18 tests reveal (and the generator or the tests check them):
- Unicode 18's GB9c is
Linker [Extend|Linker]* × Consonant: it no longer requires a consonant before the virama (094D × 0915). - the line breaking rules follow the numbering of the UCD's own
LineBreakTest.html(15.11, 19.13, 28.14…), which is the numbering of the test file. - in the UCA 18 shifted quaternary, the second element of an implicit weight (
[.BBBB.0000.0000]) does not get FFFF, and U+FFFE (primary 0200) gets 0001. The BBBB of the@implicitweightsranges counts from the first range with the same base (the Tangut supplement continues Tangut). - in UTS 46, the mapping is NFKC_Casefold. The generator confirms this for all code points, and stores only the status of each one and three exceptions (ẞ, 。, 。). In transitional mode, a deviation that comes out of a mapping is also mapped (ẞ → ß → ss).
Collation is the root (DUCET), without CLDR. The ordering for each CLDR language is megabytes of data and years of maintenance. Instead, CCollationTailoring: a small format of adjustments that the user writes for their language, of the type "X comes right after Y, at level L" (&Y < X, &Y << X, &Y <<< X from CLDR). This is enough for Spanish ñ, Czech ch, Danish å. It does not do "before", does not reorder scripts and does not have the dozens of CLDR options. Up to 64 rules, items of up to 8 code points, contiguous (without the root's discontiguous contractions).
Collation and skeletons run over NFD, streaming, in a window on the stack. More than 30 consecutive combining marks are cut as in the UAX 15 Stream-Safe Text Format (a virtual CGJ every 30). That is what keeps them free of dynamic memory, and it only changes text that no language writes.
Numeric collation compares numbers by value, without leading zeros ("001" = "1" up to the tertiary level. The identical level separates them). More than 56,799 consecutive digits are compared only by length and by the first digits. This never happens in text written by people.
The case level comes from the tertiary level: the tertiary weights that are, in the data, those of uppercase letters (08 to 0C, computed by the generator against the Uppercase property, and not copied from memory).
Line breaking is UAX 14 by default, without a dictionary: scripts without spaces between words (Thai, Lao, Khmer, Burmese, the SA class) do not break inside words, only at spaces. A dictionary engine is FormaUI's job, if it asks for one.
Width (ColumnWidth, StringWidth): 0 for control characters, combining marks (Mn, Me), Default_Ignorable, line and paragraph separators and Hangul vowels/finals. 2 for East_Asian_Width W and F. 1 for the rest, including the "ambiguous" ones, unless requested. A text is measured per grapheme: the grapheme takes the width of its widest code point, and 2 with the emoji presentation selector (U+FE0F) on an emoji or a keycap, or on a flag.
The Console uses Text when it is built (Cli::CodePointWidth, TextWidth, BytesForColumns): per grapheme, and without breaking a flag. Without Text (or without segmentation), it keeps its compact table. The choice is made in one place only, in src/cpp/cli/width.cpp. Neither module depends on the other. Invalid bytes now count per maximal subpart (the Unicode recommendation).
IDNA: the default options are the ones UTS 46 recommends for a client (nontransitional, with all checks, STD3, ContextJ, the bidi rule, and the DNS length in ToAscii). All errors are reported, with the UTS 46 codes (IdnaError), and ToUnicode writes the result even for an invalid name (useful for displaying it). Each label is processed on the stack: more than 256 code points after mapping is kLabelTooLong (DNS accepts 63 bytes).
Confusables are the UTS 39 skeleton (NFD, without ignorables, prototypes, NFD). They do not do the rest of UTS 39 (mixed scripts, restriction profiles), and this page does not promise that.
Bidi goes up to L2. L3 (combining marks in rendering) belongs to the text engine. L4 is MirroredGlyph. L1 treats the paragraph as one line. For word-wrapped text, BidiLineEnd applies the end of each line and BidiReorder reorders it. Each paragraph separator (B) closes a paragraph (P1).
Backward segmentation is linear because each position is decided on its own, with the limited context the rules require. The exception is regional indicator parity, which is genuinely global: the iterator knows it from being on a boundary. PrevBoundary and IsBoundary on their own count the flag sequence they land in.
The C layer came later (2026-10, CABI project). The Text spec did not ask for it. See the section below.
---
C layer
Header ethereal/c/text/text.h (source src/c/text/text.cpp, inside ETHEREAL_TEXT), 36 ETLC_Text* functions. UTF-8 texts with pointer and size, output in the caller's buffer with capacity and written size. It covers the properties of a code point (general category with ETLC_TEXT_GC_* macros, the binary bits, the combining class, the numeric value, the short and long names and the script and category lookup by name), code point counting, case (uppercase, lowercase, title case, folding, case-insensitive comparison and the simple mappings), normalization (NFC, NFD, NFKC, NFKD), grapheme, word and sentence boundaries (next, previous, whether it is a boundary and count), collation (comparison, sort key and tailoring sets), bidi (levels, reordering, visual order and mirroring) and IDN (ToAscii, ToUnicode, Punycode, skeleton and confusables).
Each capability with its own table only calls the C++ with its macro (ETL_TEXT_NORMALIZATION, ETL_TEXT_SEGMENTATION, ETL_TEXT_COLLATION, ETL_TEXT_BIDI, ETL_TEXT_IDN). Without the macro, the function remains exported and returns ETLC_ERR_UNSUPPORTED, so the ABI does not change with the options. The values for bidi, line break, script and the like are the numbers from the generated tables, which follow the Unicode version: the stable identity is the name.
Left out are the chunked normalizer (CNormalizer), the segment and line break iterators (the boundary functions cover the segments) and layout (width and truncation), which the console C layer already measures with ETLC_TextWidth.
Tests text.cabi.c11 and text.cabi.c17 (tests/text_c_abi.c, only with ETHEREAL_TEXT): each capability with the values from the C++ tests when the macro exists, and the ETLC_ERR_UNSUPPORTED refusal when it does not.
---
Status, against the spec (section 4)
| Criterion | Status |
|---|---|
| Conformance with the official files | ✅ 100% on all of them (the "Conformance" table above), on GCC and MSVC |
| Table size | ✅ 371.6 K the module, 90.5 K properties only. Published above |
| Property lookup | ✅ 2.2 to 2.6 ns |
| NFC check of ASCII | ✅ 39 to 44 GB/s |
| Normalization | ✅ 780 to 900 MB/s already normalized. 138 to 197 MB/s with work |
| Case-insensitive comparison | ✅ ASCII is resolved without tables. Zero allocations verified |
Turkish i | ✅ correct with the option, and not applied by default |
| Chunked normalization | ✅ equal to the one-shot result with the text split at every byte |
| Sort keys | ✅ memcmp of the keys = Compare on 30,000 random pairs (all options), on the CollationTest lines and on 600 long texts |
| Graphemes | ✅ ZWJ sequences and flags are never broken, also when truncating |
| IDN | ✅ the entire IdnaTestV2, results and error codes |
| CMake options | ✅ each one removes its own tables (measured above). All 7 configurations build without Text warnings and pass the tests they have |
| Allocations | ✅ zero on every path with std::span, verified with ETL_EXPECT_NO_ALLOC |
| Fuzzing | ✅ normalizer, segmentation, line breaking, collation, IDNA and bidi (text_fuzz), clean under ASan and UBSan with 3 seeds |
| Sanitizers | ✅ ASan and UBSan clean on all Text tests |
Do the tests test what they claim? A campaign of 25 mutants (tools/text_check/mutants_text.py) breaks each rule the code implements, one at a time, and checks that some test catches the break: 25 out of 25. Three of them needed work, and we recorded which. Two did not apply (the text to change no longer existed in the code) and were fixed. The third survived: "LV composes with the T of index 0 (U+11A7)" is equivalent. U+11A7 is a safe code point, the slow region always ends before it, and that composition is never attempted. This was noted in the script, and the mutant was replaced with a reachable one (the last T, U+11C2, no longer composing), which the tests catch. The U+11A7 cases remain in the tests.
And a defect in the tests themselves, found while writing Regex. Five of these files wrote ETL_EXPECT_NO_ALLOC; with a semicolon. The macro is a for: with ; the scope is empty, and the test passed without measuring anything. They were fixed to the documented form (ETL_EXPECT_NO_ALLOC { … }) and pass: the paths really do not allocate.