View source code Display the source code in std/base64.d from which this page was generated on github. Improve this page Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone. Page wiki View or edit the community-maintained wiki page associated with this page.

Function std.base64.Base64Impl.decodeLength

Given a Base64 encoded string, calculates the length of the decoded string.

Prototype

size_t decodeLength(
  size_t sourceLength
) pure nothrow @safe;

Parameters

NameDescription
sourceLength The length of the Base64 encoding.

Returns

The length of the decoded string corresponding to a Base64 encoding of length sourceLength.

Example

auto encoded = "Gis8TV1u";

// Allocate a sufficiently large buffer to hold to decoded result.
auto buffer = new ubyte[Base64.decodeLength(encoded.length)];

Base64.decode(encoded, buffer);
assert(buffer == [0x1a, 0x2b, 0x3c, 0x4d, 0x5d, 0x6e]);


Authors

Masahiro Nakagawa, Daniel Murphy (Single value Encoder and Decoder)

License

Boost License 1.0.

Comments