![]() |
VOOZH | about |
dotnet add package Gapotchenko.FX.Data.Encoding --version 2026.7.2
NuGet\Install-Package Gapotchenko.FX.Data.Encoding -Version 2026.7.2
<PackageReference Include="Gapotchenko.FX.Data.Encoding" Version="2026.7.2" />
<PackageVersion Include="Gapotchenko.FX.Data.Encoding" Version="2026.7.2" />Directory.Packages.props
<PackageReference Include="Gapotchenko.FX.Data.Encoding" />Project file
paket add Gapotchenko.FX.Data.Encoding --version 2026.7.2
#r "nuget: Gapotchenko.FX.Data.Encoding, 2026.7.2"
#:package Gapotchenko.FX.Data.Encoding@2026.7.2
#addin nuget:?package=Gapotchenko.FX.Data.Encoding&version=2026.7.2Install as a Cake Addin
#tool nuget:?package=Gapotchenko.FX.Data.Encoding&version=2026.7.2Install as a Cake Tool
Gapotchenko.FX.Data.Encoding module provides a quasi-universal framework for data encodings.
It supports both synchronous and asynchronous data processing models, including the iterative transcoding.
The module serves as the implementation basis for a variety of popular encodings: Base16, Base32, Base64, and others.
ITextDataEncodingThis is the root interface provided by a binary-to-text data encoding algorithm. The interface has several notable methods.
GetString(ReadOnlySpan<byte> data)This method encodes all the bytes in the specified span into a string.
For example, GetString method of a Base16 encoding would be used like this:
using Gapotchenko.FX.Data.Encoding;
var data = new byte[] { 1, 2, 3, 10 };
var s = Base16.GetString(data);
Console.WriteLine(s);
producing the following output:
0102030A
The GetString method can also take options.
Here is an example that would produce the indented output:
var data = new byte[] { 1, 2, 3, 10 };
var s = Base16.GetString(data, DataEncodingOptions.Indent);
Console.WriteLine(s);
The output:
01 02 03 0A
Note that the output now contains space separators (indentations) between the encoded data values.
Not all encodings support indentation so Indent option flag may be ignored by some of them.
GetBytes(ReadOnlySpan<char> s)The method decodes all the characters in the specified read-only span into a byte array.
In this way, GetBytes method performs a reverse operation to GetString.
For example, GetBytes method of a Base16 encoding can be used like this:
using Gapotchenko.FX.Data.Encoding;
byte[] data = Base16.GetBytes("0102030A");
foreach (var i in data)
Console.WriteLine(i);
producing the following output:
1
2
3
10
CreateEncoder(TextWriter textWriter)The method creates a streaming encoder for the specified binary-to-text data encoding.
Example:
using Gapotchenko.FX.Data.Encoding;
using System.IO;
var encoding = Base16.Instance;
// Create a destination text writer.
var sw = new StringWriter();
// Create a streaming encoder.
var stream = encoding.CreateEncoder(sw);
// Stream the data.
stream.Write(1);
stream.Write(2);
stream.Write(3);
stream.Write(10);
// Flush the data.
stream.Flush();
Console.WriteLine(sw.ToString());
The output:
0102030A
It is worth mentioning that the streaming encoder also supports the asynchronous operations.
CreateDecoder(TextReader textReader)The method creates a streaming decoder for the specified binary-to-text data encoding.
It can be viewed as a reverse operation to CreateEncoder and it fully supports the asynchronous operations as well.
Imagine a Base64-encoded file that needs to be converted to Base32. The file is pretty large, around 2 gigabytes of data.
A naive approach would be to read all the data from the file beforehand in order to re-encode it later:
using Gapotchenko.FX.Data.Encoding;
using System.IO;
// Read the file.
var text = File.ReadAllText("2GB-base64.txt");
// Decode the Base64 data.
var data = Base64.GetBytes(text);
// Re-encode the data with Base32 encoding.
text = Base32.GetString(data);
// Save the new file.
File.WriteAllText("2GB-base32.txt", text);
It will work but obviously will consume at least 2 GB of RAM.
This is when the concept of streaming becomes handy. A better transcoding algorithm can use just a fraction of RAM to perform the very same operation of re-encoding a Base64-encoded file to Base32:
using Gapotchenko.FX.Data.Encoding;
using System.IO;
var sourceEncoding = Base64.Instance;
var destinationEncoding = Base32.Instance;
// Open the source file.
using var sourceTextReader = File.OpenText("2GB-base64.txt");
// Create the destination file.
using var destinationTextWriter = File.CreateText("2GB-base32.txt");
// Create a streaming decoder for the Base64-encoded source file.
var sourceStream = sourceEncoding.CreateDecoder(sourceTextReader);
// Create a streaming encoder for the Base32-encoded destination file.
var destinationStream = destinationEncoding.CreateEncoder(destinationTextWriter);
// Transcode the file by copying the source stream to destination.
sourceStream.CopyTo(destinationStream);
destinationStream.Flush();
The transcoding algorithm based on streaming codecs presented above is highly efficient in terms of memory usage and consumes just a few kilobytes of RAM to transcode a file of any size.
Gapotchenko.FX.Data.Encoding module provides only the framework for data encoding algorithms.
If you want to use a ready-to-use algorithm, Gapotchenko.FX provides quite a few out of the box:
| Algorithm Family | Module | Algorithms |
|---|---|---|
| Base16 | Gapotchenko.FX.Data.Encoding.Base16 | Base16 |
| Base24 | Gapotchenko.FX.Data.Encoding.Base24 | Kuon Base24 |
| Base32 | Gapotchenko.FX.Data.Encoding.Base32 | Base32, base32-hex, Crockford Base 32, z-base-32 |
| Base64 | Gapotchenko.FX.Data.Encoding.Base64 | Base64, Base64 URL |
Moreover, you can create your own data encoding algorithm.
Gapotchenko.FX project welcomes contributions, or it can be a standalone NuGet package that uses Gapotchenko.FX.Data.Encoding module as a wireframe.
Let's continue with a look at some other modules provided by Gapotchenko.FX:
Or look at the full list of modules.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 is compatible. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 is compatible. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 4 NuGet packages that depend on Gapotchenko.FX.Data.Encoding:
| Package | Downloads |
|---|---|
|
Gapotchenko.FX.Data.Encoding.Base32
Provides Base32 data encoding algorithms: Base32, base32-hex, Crockford Base 32, z-base-32. |
|
|
Gapotchenko.FX.Data.Encoding.Base64
Provides Base64 data encoding algorithms: Base64, Base64 URL. |
|
|
Gapotchenko.FX.Data.Encoding.Base16
Provides Base16 data encoding algorithms. |
|
|
Gapotchenko.FX.Data.Encoding.Base24
Provides Base24 data encoding algorithms. |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2026.7.2 | 278 | 5/16/2026 |
| 2026.6.2 | 311 | 3/29/2026 |
| 2026.5.3 | 328 | 2/24/2026 |
| 2026.4.2 | 298 | 2/4/2026 |
| 2026.3.5 | 308 | 1/29/2026 |
| 2026.2.2 | 301 | 1/25/2026 |
| 2026.1.5 | 302 | 1/13/2026 |
| 2025.1.45 | 401 | 12/25/2025 |
| 2025.1.27-beta | 369 | 10/8/2025 |
| 2025.1.26-beta | 402 | 8/30/2025 |
| 2025.1.25-beta | 1,032 | 7/22/2025 |
| 2025.1.24-beta | 362 | 7/16/2025 |
| 2025.1.23-beta | 295 | 7/12/2025 |
| 2024.2.5 | 1,257 | 12/31/2024 |
| 2024.1.3 | 588 | 11/10/2024 |
| 2022.2.7 | 2,356 | 5/1/2022 |
| 2022.2.5 | 735 | 5/1/2022 |