Table of Contents

BaseFormattingOptions Enum

Definition

Namespace
Bodu.Text.Encoding
Assembly
Bodu.Text.Encoding.dll
Package
Bodu.Text.Encoding 1.0.0
Source
BaseFormattingOptions.cs

Defines formatting options that influence how encoded output is generated from binary data using any positional numeral system.

[Flags]
public enum BaseFormattingOptions : byte
Attributes
Extension Methods

Fields

None = 0

No formatting is applied. The output is compact, lower case, and continuous with no spacing, prefix, or line breaks.

UpperCase = 1

Formats the encoded output using upper case characters.

InsertLineBreaks = 2

Inserts line breaks (\r\n) into the output at a fixed interval. The exact column at which breaks are inserted is encoding-specific.

IncludePrefix = 4

Adds a standard prefix to the output denoting the encoding. The prefix format is encoding-specific (for example, 0x for Base16).

InsertSpacing = 8

Inserts a single space between adjacent groups of encoded symbols, typically aligned to byte boundaries.

OmitPadding = 16

Omits the trailing padding characters that the encoding specification would normally emit. This flag has no effect on encodings that do not use padding.

Examples

// Compact lower-case hex (the default Base16 form).
string compact = Base16.Encode(data);

// Diagnostic-friendly: upper case, "0x" prefix, single-space byte groups.
string diagnostic = Base16.Encode(data,
    BaseFormattingOptions.UpperCase
    | BaseFormattingOptions.IncludePrefix
    | BaseFormattingOptions.InsertSpacing);

// Padding-free Base64 - produces the same output as Base64Url.Encode.
string unpadded = Base64.Encode(data, BaseFormattingOptions.OmitPadding);

Remarks

These options can be combined to control character casing, spacing, prefix inclusion, and line formatting. The effect of each option may vary by encoding; not every encoding honours every flag. Refer to the documentation of the specific encoder for the supported subset.

None produces the most compact form for every encoder. Flag combinations that conflict (for example OmitPadding on an encoding that does not emit padding) are silently ignored rather than rejected, so consumers can compose options uniformly across encoders without conditional branching.

Applies to

ProductVersions
.NET8, 10