Bodu.Text.Encoding
1.3.0
dotnet add package Bodu.Text.Encoding --version 1.3.0
NuGet\Install-Package Bodu.Text.Encoding -Version 1.3.0
<PackageReference Include="Bodu.Text.Encoding" Version="1.3.0" />
<PackageVersion Include="Bodu.Text.Encoding" Version="1.3.0" />
<PackageReference Include="Bodu.Text.Encoding" />
paket add Bodu.Text.Encoding --version 1.3.0
#r "nuget: Bodu.Text.Encoding, 1.3.0"
#:package Bodu.Text.Encoding@1.3.0
#addin nuget:?package=Bodu.Text.Encoding&version=1.3.0
#tool nuget:?package=Bodu.Text.Encoding&version=1.3.0
Bodu.Text.Encoding
API stability - Stable. The public API surface is committed: breaking changes are reserved for a major-version bump per SemVer, except a deliberate break that is recorded in the release notes and in the package's
CompatibilitySuppressions.xml. See versioning and support.
Binary-to-text encodings for .NET 8 and .NET 10 - Base16, Base32, Base45, Base58, Base62, Base64, Base85, and Bech32, plus Base58Check, Base64Url, percent-encoding, and quoted-printable - with a uniform static API, variant selection, encode-time formatting options, and decode-time leniency styles. The five core encodings (Base16, Base32, Base58, Base64, Base85) expose span, string, UTF-8, and IBufferWriter<> surfaces with Try* and length-calculation overloads for allocation-free use.
Installation
dotnet add package Bodu.Text.Encoding
Targets net8.0 and net10.0. All types live in the Bodu.Text.Encoding namespace.
Encodings and variants
| Encoding | Variants (*Variant enum) |
Notes |
|---|---|---|
Base16 |
Lower, Upper |
Hexadecimal |
Base32 |
Standard (RFC 4648), HexExtended (RFC 4648 §7), Crockford, ZBase32 |
|
Base45 |
- | RFC 9285 (QR payloads) |
Base58 |
BitcoinFlickr (the Bitcoin alphabet), Ripple, Flickr |
Base58Check adds a checksum for address-style payloads |
Base62 |
- | |
Base64 |
Standard (RFC 4648), UrlSafe (§5), Mime (RFC 2045) |
Base64Url is Base64 with UrlSafe bound; it accepts input with or without padding |
Base85 |
Ascii85 (Adobe/PDF), Z85 (ZeroMQ), GitCompact (Git binary patches) |
|
Bech32 |
Bech32Encoding checksum variants |
API shape
Each encoding is a static class with a consistent surface:
using Bodu.Text.Encoding;
string hex = Base16.Encode(data, Base16Variant.Upper);
byte[] back = Base16.Decode(hex);
// Variant + formatting options
string b64 = Base64.Encode(data, Base64Variant.UrlSafe, BaseFormattingOptions.OmitPadding);
// Allocation-free
Span<char> dest = stackalloc char[Base32.GetEncodedLength(data.Length)];
Base32.TryEncode(data, dest, out int written, Base32Variant.Crockford);
Encode/Decode,TryEncode/TryDecode,GetEncodedLength/GetDecodedLength.- UTF-8 surfaces (
EncodeToUtf8,DecodeFromUtf8) andIBufferWriter<byte>/IBufferWriter<char>overloads, as static members of the five core encodings. BinaryEncodingsprovides variant-awareIBinaryEncodinginstances for polymorphic selection.
BaseFormattingOptions (encode) toggles casing, line breaks, prefixes, spacing, and padding omission; BaseFormatStyles (decode) controls leniency - prefix tolerance, whitespace skipping, missing padding, and canonical-form enforcement.
Runnable samples
The repository ships offline, dotnet run-able sample projects for this package - the
catalogue and variant tour, the formatting/parse-style knobs, checksummed Base58Check and
Bech32 corruption detection, the BinaryEncodings registry, and a custom Base36 codec proven
by the shipped contract-test base - under
samples/Text.Encoding/.
Building and testing
To build this package from source and run its tests, see CONTRIBUTING.md. The published vectors and corpora the tests hold it to are listed under conformance and test vectors.
License
MIT. © Bodu Pty. Ltd.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.