Skip to content

Instantly share code, notes, and snippets.

@insolor
Last active April 27, 2025 18:06
Show Gist options
  • Save insolor/75960cdcf741515417da08ece119253c to your computer and use it in GitHub Desktop.
Save insolor/75960cdcf741515417da08ece119253c to your computer and use it in GitHub Desktop.
Gettext MO ImHex pattern (little endian)
import std.sys;
struct StringTableEntry {
u32 length;
char *offset[this.length] : u32;
str string = this.offset [[export]];
};
struct MOHeader {
char magic[4];
std::assert(this.magic != "\x95\x04\x12\xDE", "Big-endian MO file format is not supported");
std::assert(this.magic == "\xDE\x12\x04\x95", "Wrong file format");
u32 format_version;
u32 number_of_strings;
StringTableEntry * original_strings[this.number_of_strings] : u32;
StringTableEntry * translations[this.number_of_strings] : u32;
u32 size_of_hash_table;
u32 * hash_table[this.size_of_hash_table] : u32;
};
MOHeader mo_header @ 0x00;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment