Skip to content

OnixLabs.Core.Text.Base32FormatProvider

matthew edited this page May 27, 2026 · 1 revision

Base32FormatProvider Class

Represents a Base-32 format provider.

Namespace OnixLabs.Core.Text
Assembly OnixLabs.Core.dll (NuGet)
Inheritance object → Enumeration<Base32FormatProvider> → Base32FormatProvider
Implements IEquatable<Base32FormatProvider>, IComparable<Base32FormatProvider>, IComparable, IFormatProvider

Definition

public sealed class Base32FormatProvider : Enumeration<Base32FormatProvider>, IFormatProvider

Remarks

Base32FormatProvider is a smart enumeration that carries both the alphabet and the padding flag used by Base32Codec to encode and decode Base-32 values. It derives from Enumeration<Base32FormatProvider> and implements IFormatProvider.

Ten entries are declared, covering five widely-used alphabets in both an unpadded and a padded variant. When IsPadded is true, encoded output is padded with = characters to a multiple of eight characters, and decoding rejects input whose length is not a multiple of eight.

Because the type derives from Enumeration<T>, all entries are also available through the inherited static query methods such as GetAll, FromName, and FromValue.

Fields

Each alphabet is available in an unpadded and a padded variant. All fields are declared as public static readonly Base32FormatProvider.

Field Padded Alphabet
Rfc4648 No ABCDEFGHIJKLMNOPQRSTUVWXYZ234567
ZBase32 No ybndrfg8ejkmcpqxot1uwisza345h769
GeoHash No 0123456789bcdefghjkmnpqrstuvwxyz
Crockford No 0123456789ABCDEFGHJKMNPQRSTVWXYZ
Base32Hex No 0123456789ABCDEFGHIJKLMNOPQRSTUV
PaddedRfc4648 Yes ABCDEFGHIJKLMNOPQRSTUVWXYZ234567
PaddedZBase32 Yes ybndrfg8ejkmcpqxot1uwisza345h769
PaddedGeoHash Yes 0123456789bcdefghjkmnpqrstuvwxyz
PaddedCrockford Yes 0123456789ABCDEFGHJKMNPQRSTVWXYZ
PaddedBase32Hex Yes 0123456789ABCDEFGHIJKLMNOPQRSTUV

Rfc4648

public static readonly Base32FormatProvider Rfc4648;

The unpadded RFC 4648 Base-32 format provider. Alphabet ABCDEFGHIJKLMNOPQRSTUVWXYZ234567. This is the default provider used by Base32Codec.

ZBase32

public static readonly Base32FormatProvider ZBase32;

The unpadded Z-Base-32 format provider. Alphabet ybndrfg8ejkmcpqxot1uwisza345h769. Z-Base-32 is a human-oriented encoding designed to be easier to read and type than RFC 4648.

GeoHash

public static readonly Base32FormatProvider GeoHash;

The unpadded GeoHash Base-32 format provider. Alphabet 0123456789bcdefghjkmnpqrstuvwxyz. Used by the GeoHash geographic coordinate system.

Crockford

public static readonly Base32FormatProvider Crockford;

The unpadded Crockford Base-32 format provider. Alphabet 0123456789ABCDEFGHJKMNPQRSTVWXYZ. Douglas Crockford's Base-32 variant, designed for human readability by excluding ambiguous characters.

Base32Hex

public static readonly Base32FormatProvider Base32Hex;

The unpadded Base-32 Hex format provider. Alphabet 0123456789ABCDEFGHIJKLMNOPQRSTUV. Preserves the sort order of the underlying data when the encoded strings are compared lexicographically.

PaddedRfc4648

public static readonly Base32FormatProvider PaddedRfc4648;

The padded RFC 4648 Base-32 format provider. Same alphabet as Rfc4648 but with = padding to a multiple of eight characters.

PaddedZBase32

public static readonly Base32FormatProvider PaddedZBase32;

The padded Z-Base-32 format provider. Same alphabet as ZBase32 but with = padding to a multiple of eight characters.

PaddedGeoHash

public static readonly Base32FormatProvider PaddedGeoHash;

The padded GeoHash Base-32 format provider. Same alphabet as GeoHash but with = padding to a multiple of eight characters.

PaddedCrockford

public static readonly Base32FormatProvider PaddedCrockford;

The padded Crockford Base-32 format provider. Same alphabet as Crockford but with = padding to a multiple of eight characters.

PaddedBase32Hex

public static readonly Base32FormatProvider PaddedBase32Hex;

The padded Base-32 Hex format provider. Same alphabet as Base32Hex but with = padding to a multiple of eight characters.

Properties

Property Type Description
Alphabet string Gets the Base-32 alphabet associated with the current format provider.
IsPadded bool Gets a value indicating whether the current format provider uses padding.

Alphabet

public string Alphabet { get; }

Gets the alphabet of the current Base32FormatProvider instance.

IsPadded

public bool IsPadded { get; }

Gets a value indicating whether the current Base32FormatProvider instance uses padding. true if the current format provider uses padding; otherwise, false. When true, the associated Base32Codec pads encoded output to a multiple of eight characters with = and requires input lengths to be a multiple of eight during decoding.

Methods

Method Returns Description
GetFormat(Type?) object? Returns the current instance when formatType is typeof(Base32FormatProvider); otherwise, returns null.

GetFormat(Type?)

public object? GetFormat(Type? formatType)

Returns the current instance when formatType is typeof(Base32FormatProvider); otherwise, returns null. This is the IFormatProvider contract method that allows the format provider to be passed to any API that accepts IFormatProvider.

Parameter Type Description
formatType Type? The type of format object to obtain.

Returns — The current instance if formatType is typeof(Base32FormatProvider); otherwise, null.

See Also

ONIXLabs .NET Library


Clone this wiki locally