Implementing

Encodings

View this section in the spec ↗

An encoding maps one part of the 128-bit value to characters of the TNID string, <name>.<data>. The spec defines two, one per part; UUID hex, bytes and integers are representations, not encodings.

EncodingEncodesAlphabet / widthWhy this one
Name20 name bits ↔ the 1–4 characters before the .null, 0–4, a–z; 5 bitsA human-chosen, readable label: 32 symbols fit 4 characters into 20 bits
Data102 data bits (TNID variant + payload) ↔ the 17 characters after the .-, 0–9, A–Z, _, a–z; 6 bitsArbitrary bits, packed densely: 102 = 17 × 6, no padding

Composition

user.Br2flcNDfF6LYICnT = d6157337-0ebc-8686-83ab-4075a34cdcde:

PartIn the valueIn the stringEncoding
Name20 bits, d6157userName
Separator.
Data102 bits: TNID variant + payloadBr2flcNDfF6LYICnTData
UUID version, variant6 constant bitsOmitted

Sort order matches bit order

Value order is ASCII order in both alphabets, so sorting strings byte by byte sorts the bits. A TNID string therefore sorts like its 128-bit value.

URL safety

Both alphabets and the . are unreserved characters (RFC 3986 §2.3): no percent-encoding in URL paths, queries or fragments.

  1. 01 Name encodingThe 5-bit encoding that packs a TNID name of up to four characters into 20 bits.
  2. 02 Data encodingThe 6-bit, base64-like encoding of the 102 data bits after the dot in a TNID string.