ArrayPrinter 0.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package ArrayPrinter --version 0.1.0
NuGet\Install-Package ArrayPrinter -Version 0.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ArrayPrinter" Version="0.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ArrayPrinter --version 0.1.0
#r "nuget: ArrayPrinter, 0.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install ArrayPrinter as a Cake Addin
#addin nuget:?package=ArrayPrinter&version=0.1.0

// Install ArrayPrinter as a Cake Tool
#tool nuget:?package=ArrayPrinter&version=0.1.0

Array Printer

A F# library to format byte arrays in a human readable fashion.

F# does not provide an easy method of visualizing byte arrays (that I am aware of). For instance the output via printfn "%A" of an array like

"eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ" |> System.Convert.FromBase64String

looks like this:

[|123uy; 34uy; 115uy; 117uy; 98uy; 34uy; 58uy; 34uy; 49uy; 50uy; 51uy; 52uy;
  53uy; 54uy; 55uy; 56uy; 57uy; 48uy; 34uy; 44uy; 34uy; 110uy; 97uy; 109uy;
  101uy; 34uy; 58uy; 34uy; 74uy; 111uy; 104uy; 110uy; 32uy; 68uy; 111uy; 101uy;
  34uy; 44uy; 34uy; 105uy; 97uy; 116uy; 34uy; 58uy; 49uy; 53uy; 49uy; 54uy; 50uy;
  51uy; 57uy; 48uy; 50uy; 50uy; 125uy|]

The Array Printer Library provides a method for pretty printing such arrays.

ArrayPrinter.printArray PrinterOptions.defaults myArray

returns the string

0000  7B 22 73 75 62 22 3A 22 31 32 33 34 35 36 37 38  {"sub":"12345678
0010  39 30 22 2C 22 6E 61 6D 65 22 3A 22 4A 6F 68 6E  90","name":"John
0020  20 44 6F 65 22 2C 22 69 61 74 22 3A 31 35 31 36  .Doe","iat":1516
0030  32 33 39 30 32 32 7D                             239022}

Usage

<NuGet>

The output can be controlled via the ArrayPrinter.PrinterOptions. Defaults for Hex, Decimal, Octal and Binary display are provided via PrinterOptions.*Defaults. PrinterOptions.defaults uses Hex.

Row headers, the array content and a data interpretation of that content are the three parts of the output. The row headers and the data interpretation can be disabled:

// Disable the data part.
ArrayPrinter.printArray ({ PrinterOptions.defaults with WithData = false }) myArray

// Disable the header part.
ArrayPrinter.printArray ({ PrinterOptions.defaults with WithHeader = false }) myArray

Additionally, the width of a row can be adjusted:

// Use looong rows
ArrayPrinter.printArray ({ PrinterOptions.defaults with RowWidth = 32 }) myArray

The defaults are 16 for hex, 10 for decimal, 8 for ocal and 4 for binary (because it is so large…).

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.2.0 99 3/15/2024
0.1.1 92 3/14/2024
0.1.0 214 11/29/2023