package core:encoding/endian

⌘K
Ctrl+K
or
/

    Overview

    Package endian implements sa simple translation between bytes and numbers with specific endian encodings.

    buf: [100]u8 put_u16(buf[:], .Little, 16) or_return

    You may ask yourself, why isn't byte_order platform Endianness by default, so we can write: put_u16(buf[:], 16) or_return

    The answer is that very few file formats are written in native/platform endianness. Most of them specify the endianness of each of their fields, or use a header field which specifies it for the entire file.

    e.g. a file which specifies it at the top for all fields could do this: file_order := .Little if buf[0] == 0 else .Big field := get_u16(buf[1:], file_order) or_return

    If on the other hand a field is always Big-Endian, you're wise to explicitly state it for the benefit of the reader, be that your future self or someone else.

    field := get_u16(buf[:], .Big) or_return

    Index

    Types (1)
    Constants (1)
    Variables (0)

    This section is empty.

    Procedure Groups (0)

    This section is empty.

    Types

    Constants

    PLATFORM_BYTE_ORDER ¶

    PLATFORM_BYTE_ORDER :: Byte_Order.Little when ODIN_ENDIAN == .Little else Byte_Order.Big

    Variables

    This section is empty.

    Procedures

    get_f16 ¶

    get_f16 :: proc(b: []u8, order: Byte_Order) -> (f16, bool) {…}

    get_f32 ¶

    get_f32 :: proc(b: []u8, order: Byte_Order) -> (f32, bool) {…}

    get_f64 ¶

    get_f64 :: proc(b: []u8, order: Byte_Order) -> (f64, bool) {…}

    get_i16 ¶

    get_i16 :: proc(b: []u8, order: Byte_Order) -> (i16, bool) {…}

    get_i32 ¶

    get_i32 :: proc(b: []u8, order: Byte_Order) -> (i32, bool) {…}

    get_i64 ¶

    get_i64 :: proc(b: []u8, order: Byte_Order) -> (i64, bool) {…}

    get_u16 ¶

    get_u16 :: proc(b: []u8, order: Byte_Order) -> (v: u16, ok: bool) {…}

    get_u32 ¶

    get_u32 :: proc(b: []u8, order: Byte_Order) -> (v: u32, ok: bool) {…}

    get_u64 ¶

    get_u64 :: proc(b: []u8, order: Byte_Order) -> (v: u64, ok: bool) {…}

    put_f16 ¶

    put_f16 :: proc(b: []u8, order: Byte_Order, v: f16) -> bool {…}

    put_f32 ¶

    put_f32 :: proc(b: []u8, order: Byte_Order, v: f32) -> bool {…}

    put_f64 ¶

    put_f64 :: proc(b: []u8, order: Byte_Order, v: f64) -> bool {…}

    put_i16 ¶

    put_i16 :: proc(b: []u8, order: Byte_Order, v: i16) -> bool {…}

    put_i32 ¶

    put_i32 :: proc(b: []u8, order: Byte_Order, v: i32) -> bool {…}

    put_i64 ¶

    put_i64 :: proc(b: []u8, order: Byte_Order, v: i64) -> bool {…}

    put_u16 ¶

    put_u16 :: proc(b: []u8, order: Byte_Order, v: u16) -> bool {…}

    put_u32 ¶

    put_u32 :: proc(b: []u8, order: Byte_Order, v: u32) -> bool {…}

    put_u64 ¶

    put_u64 :: proc(b: []u8, order: Byte_Order, v: u64) -> bool {…}

    Procedure Groups

    This section is empty.

    Source Files

    Generation Information

    Generated with odin version dev-2023-10 (vendor "odin") Windows_amd64 @ 2023-10-03 21:09:46.814178500 +0000 UTC