EncodeBase64W

Function to encode any data input array into a BASE64 string.

The output string has to be allocated by the host. The return value defines the length of the string size in bytes.

Terminator adds a 0 element to the end of the BASE64 generated string, it will NOT increase the length.

If output is nullptr the length will be calculated but the string itself will not be generated.

Syntax

//
//   Strong typing definition
//
int64_t         EncodeBase64W(
                        wchar_t                 * output,
                        const unsigned char     * input,
                        int64_t                 size,
                        bool                    terminator
                    );

static  inline  int64_t EncodeBase64W(
                                wchar_t                 * output,
                                const unsigned char     * input,
                                int64_t                 size
                            )
{
    return  EncodeBase64W(
                    output,
                    input,
                    size,
                    false                               //    terminator
                );
}

static  inline  wchar_t * EncodeBase64W(
                                const unsigned char     * input,
                                int64_t                 size
                            )
{
    wchar_t * output = new wchar_t[EncodeBase64(nullptr, input, size) / sizeof(wchar_t) + 1];

    EncodeBase64W(
            output,
            input,
            size,
            true                                //    terminator
        );

    return  output;
}


//
//   Weak typing definition
//
int64_t __declspec(dllexport) __stdcall EncodeBase64W(
                                                wchar_t                 * output,
                                                const unsigned char     * input,
                                                int64_t                 size,
                                                bool                    terminator
                                            );

static  inline  int64_t EncodeBase64W(
                                wchar_t                 * output,
                                const unsigned char     * input,
                                int64_t                 size
                            )
{
    return  EncodeBase64W(
                    output,
                    input,
                    size,
                    false                               //    terminator
                );
}

static  inline  wchar_t * EncodeBase64W(
                                const unsigned char     * input,
                                int64_t                 size
                            )
{
    wchar_t * output = new wchar_t[EncodeBase64(nullptr, input, size) / sizeof(wchar_t) + 1];

    EncodeBase64W(
            output,
            input,
            size,
            true                                //    terminator
        );

    return  output;
}
    

Property output

Size: 32 bit / 4 byte (reference)
???.

Property input

Size: 32 bit / 4 byte (reference)
???.

Property size

Size: 64 bit / 8 byte (value)
The given size.

Property terminator

Size: 8 bit / 1 byte (value)
If defined the generated string will have an added terminator (zero).