BaseFormattingOptions Enum
Definition
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 = 0No formatting is applied. The output is compact and continuous with no spacing, prefix, or line breaks, in each encoding's default case (lower case for Base16).
UpperCase = 1Formats the encoded output using upper case characters.
InsertLineBreaks = 2Inserts line breaks (
\r\n) into the output at a fixed interval. The exact column at which breaks are inserted is encoding-specific.IncludePrefix = 4Adds a standard prefix to the output denoting the encoding. The prefix format is encoding-specific (for example,
0xfor Base16).InsertSpacing = 8Inserts a single space between adjacent groups of encoded symbols, typically aligned to byte boundaries.
OmitPadding = 16Omits 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 Standard Base64 (still the '+' and '/' alphabet; Base64Url.Encode uses '-' and '_').
string unpadded = Base64.Encode(data, options: 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 honors 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
| Product | Versions |
|---|---|
| .NET | 8, 10 |