1 unstable release

0.2.0 Jan 7, 2024

#4 in #rst


Used in cdragon

MIT/Apache

33KB
535 lines

CDragon library for RST files

Library to work with RST translation files used by Riot for League of Legends.


lib.rs:

Support of Riot translation files (RST)

Use [Rst] to open an RST file (.stringtable) and access its content.

An RST file maps hashed translation keys to translation strings. When an instance is created, the file header is parsed, data is read, but strings are actually read and parsed (as UTF-8) only on access.

Example


let rst = Rst::open("main_en_us.stringtable").expect("failed to open or read data");
// Get an entry by its key string
assert_eq!(rst.get("item_1001_name"), Some("Boots".into()));
// Or by its key hash
assert_eq!(rst.get(0x3376eae1da), Some("Boots".into()));

// Entries can be iterated
// Use a mapper to filter on (known) keys
let hmapper = RstHashMapper::from_path("hashes.rst.txt").expect("failed to load hashes");
for (hash, value) in rst.iter() {
    if let Some(key) = hmapper.get(hash) {
        println!("{key} = {value}");
    }
}

Older RST versions

Hash bit size

Hashes from RST files used more bits. Number of bits used by an RST file can be retrieved with [Rst::hash_bits()]. The default [RstHashMapper] is suitable for the latest RST version.

Encrypted entries

Older RST versions could have encrypted entries whose data is not valid UTF-8. Use [Rst::get_raw()] to access both encrypted and non-encrypted entries.

Dependencies

~1.5–2.6MB
~53K SLoC