Name encoding
View this section in the spec ↗Covers the 20 name bits (UUID hex digits 1–5), written as the 1–4 characters before the . in a TNID string: 4 characters × 5 bits.
Alphabet
32 values: null (00000, padding only), 0–4, a–z. Value order is ASCII order, so names sort the same as strings and as bits: "a" < "b" < "z" both ways. Full table under Mapping.
Padding
Names shorter than 4 characters MUST be null-padded at the end (least significant bits). At least one character MUST be non-null.
"ab" encoded (20 bits):
✓ Valid: [00110][00111][00000][00000]
a b null null
✗ Invalid: [00110][00000][00111][00000]
a null b null
(non-null after null is invalid)Validity
Reading name bits from a 128-bit value, reject:
- all four characters null (empty name);
- a non-null character after a null.
Every other combination is valid: all 32 values are a character or null.
Worked examples
Encoding "ab":
- Look up:
a=00110,b=00111. - Concatenate:
0011000111. - Null-pad to 20 bits:
00110001110000000000. - Regroup into nibbles:
00110001110000000000=0x31C00.
The 20-bit value is also the first five hex digits of the UUID:
| Name | Bits | Hex |
|---|---|---|
a | 00110 00000 00000 00000 | 30000 |
0 | 00001 00000 00000 00000 | 08000 |
ab | 00110 00111 00000 00000 | 31c00 |
a1b2 | 00110 00010 00111 00011 | 308e3 |
post | 10101 10100 11000 11001 | ad319 |
test | 11001 01010 11000 11001 | cab19 |
user | 11010 11000 01010 10111 | d6157 |
zzzz | 11111 11111 11111 11111 | fffff |
Mapping
Value = position in 01234abcdefghijklmnopqrstuvwxyz, counting from 1; null is 0. Read each column top to bottom.
00000 null 01000 c 10000 k 11000 s
00001 0 01001 d 10001 l 11001 t
00010 1 01010 e 10010 m 11010 u
00011 2 01011 f 10011 n 11011 v
00100 3 01100 g 10100 o 11100 w
00101 4 01101 h 10101 p 11101 x
00110 a 01110 i 10110 q 11110 y
00111 b 01111 j 10111 r 11111 z