Skip to main content

Module tlk

Module tlk 

Source
Expand description

Talk table (TLK) binary support. TLK V3.0 binary reader and writer.

TLK is the global talk table format used for localized game strings. Entries store flags, optional voice-over resrefs, and text offsets into a shared string blob.

§Shape of the container

A fixed 20-byte header, an entry table starting immediately after it, and a text blob at entries_offset. Each entry’s text_offset is measured from the blob rather than from the start of the file, so the two offsets compose rather than one superseding the other.

Two things to know before touching a reader here. The engine does not validate the version tag but does use it to pick the entry stride, so a mistyped version parses at the wrong width instead of failing. And there is no encoding declaration in the file at all: language_id selects it, and we enforce that mapping strictly rather than guessing, so a mislabelled table fails loudly instead of producing mojibake.

Byte-level field maps for the header and the entry record live in docs/src/formats/text/tlk.md, with the engine’s own load sequence.

Structs§

Tlk
In-memory representation of a TLK talk table.
TlkEntry
One TLK string entry and its metadata flags.

Enums§

TlkBinaryError
Errors produced while parsing or serializing TLK binary data.

Functions§

read_tlk
Reads a TLK from a reader.
read_tlk_from_bytes
Reads a TLK from in-memory bytes.
write_tlk
Writes a TLK to a writer in KotOR TLK V3.0 binary format.
write_tlk_to_vec
Serializes a TLK to a byte vector in KotOR TLK V3.0 format.