Zig 0.17.0-dev (Split by item)

This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig library itself.

Language

https://learn.microsoft.com/en-us/windows/win32/intl/language-identifiers

res.Language
pub const Language = packed struct(u16)

File

Code

pub const Language = packed struct(u16) {
    // Note: This is the default no matter what locale the current system is set to,
    //       e.g. even if the system's locale is en-GB, en-US will still be the
    //       default language for resources in the Win32 rc compiler.
    primary_language_id: u10 = lang.LANG_ENGLISH,
    sublanguage_id: u6 = lang.SUBLANG_ENGLISH_US,

    /// Default language ID as a u16
    pub const default: u16 = (Language{}).asInt();

    pub fn fromInt(int: u16) Language {
        return @bitCast(int);
    }

    pub fn asInt(self: Language) u16 {
        return @bitCast(self);
    }

    pub fn format(language: Language, w: *std.Io.Writer) std.Io.Writer.Error!void {
        const language_id = language.asInt();
        const language_name = language_name: {
            if (std.enums.fromInt(lang.LanguageId, language_id)) |lang_enum_val| {
                break :language_name @tagName(lang_enum_val);
            }
            if (language_id == lang.LOCALE_CUSTOM_UNSPECIFIED) {
                break :language_name "LOCALE_CUSTOM_UNSPECIFIED";
            }
            break :language_name "<UNKNOWN>";
        };
        try w.print("{s} (0x{X})", .{ language_name, language_id });
    }
}