package core:encoding/base64

⌘K
Ctrl+K
or
/

    Overview

    Base64 encoding and decoding.

    A secondary param can be used to supply a custom alphabet to encode and a matching decoding table to decode.

    If none is supplied it just uses the standard Base64 alphabet.

    By default encode emits padding. Encode options can omit it: with {.No_Padding} the output is the canonical unpadded ("raw") form of RFC 4648 section 3.2, and encoded_len reports the shorter length.

    By default decode is lenient, accepting padded and unpadded input and not checking the trailing padding bits. Decode options can enable strict (RFC 4648 section 3.5) canonical decoding: {.Strict} requires correct padding and zero trailing bits, while {.Strict, .No_Padding} accepts only canonical unpadded input.

    Types

    Decode_Error ¶

    Decode_Error :: enum int {
    	None, 
    	Invalid_Character, 
    	Invalid_Padding, 
    	Non_Canonical, 
    	Malformed_Quantum, 
    }

    Decode_Option ¶

    Decode_Option :: enum int {
    	Strict, 
    	No_Padding, 
    }
     

    Decode_Option selects optional validation performed by the decode routines.

    Decode_Options ¶

    Decode_Options :: bit_set[Decode_Option; u8]
     

    Decode_Options is a set of Decode_Option values.

    Related Procedures With Parameters

    Encode_Option ¶

    Encode_Option :: enum int {
    	No_Padding, 
    }
     

    Encode_Option selects optional behavior of the encode routines.

    Encode_Options ¶

    Encode_Options :: bit_set[Encode_Option; u8]
     

    Encode_Options is a set of Encode_Option values.

    Related Procedures With Parameters

    Constants

    Variables

    DEC_TABLE ¶

    @(rodata)
    DEC_TABLE: [256]i8 = …

    DEC_URL_TABLE ¶

    @(rodata)
    DEC_URL_TABLE: [256]i8 = …
     

    Decoding table for Base64url variant

    ENC_TABLE ¶

    @(rodata)
    ENC_TABLE: [64]u8 = …

    ENC_URL_TABLE ¶

    @(rodata)
    ENC_URL_TABLE: [64]u8 = …
     

    Encoding table for Base64url variant

    Procedures

    decode ¶

    decode :: proc(
    	data:      string, 
    	DEC_TBL:   [256]i8 = DEC_TABLE, 
    	dst:       []u8 = nil, 
    	allocator := context.allocator, 
    	options:   bit_set[Decode_Option; u8] = Decode_Options{}, 
    ) -> (decoded: []u8, err: Error) {…}

    decode_into ¶

    decode_into :: proc(
    	w:       io.Stream, 
    	data:    string, 
    	DEC_TBL: [256]i8 = DEC_TABLE, 
    	options: bit_set[Decode_Option; u8] = Decode_Options{}, 
    ) -> Error {…}

    decode_into_buf ¶

    decode_into_buf :: proc(
    	dst:     []u8, 
    	data:    string, 
    	DEC_TBL: [256]i8 = DEC_TABLE, 
    	options: bit_set[Decode_Option; u8] = Decode_Options{}, 
    ) -> (decoded: []u8, err: Error) {…}

    decoded_len ¶

    decoded_len :: proc(
    	data:    string, 
    	DEC_TBL: [256]i8 = DEC_TABLE, 
    	options: bit_set[Decode_Option; u8] = {}, 
    ) -> (n: int, err: Decode_Error) {…}

    encode ¶

    encode :: proc(
    	data:      []u8, 
    	ENC_TBL:   [64]u8 = ENC_TABLE, 
    	allocator := context.allocator, 
    	options:   bit_set[Encode_Option; u8] = Encode_Options{}, 
    ) -> (encoded: string, err: runtime.Allocator_Error) #optional_ok {…}

    encode_into ¶

    encode_into :: proc(
    	w:       io.Stream, 
    	data:    []u8, 
    	ENC_TBL: [64]u8 = ENC_TABLE, 
    	options: bit_set[Encode_Option; u8] = Encode_Options{}, 
    ) -> io.Error {…}

    encode_into_buf ¶

    encode_into_buf :: proc(
    	dst, data: []u8, 
    	ENC_TBL:   [64]u8 = ENC_TABLE, 
    	options:   bit_set[Encode_Option; u8] = Encode_Options{}, 
    ) -> (encoded: []u8, err: Error) {…}

    encoded_len ¶

    encoded_len :: proc(data: []u8, options: bit_set[Encode_Option; u8] = Encode_Options{}) -> int {…}

    Procedure Groups

    This section is empty.

    Source Files

    Generation Information

    Generated with odin version dev-2026-11 (vendor "odin") Windows_amd64 @ 2026-11-20 21:05:09.319432300 +0000 UTC