Swiss Army Knife
General utility tools for Scada Minds
Static Public Member Functions | List of all members
Gzip Class Reference

Various utility functions for working with Gzip. More...

Static Public Member Functions

static byte[] Compress (byte[] dataToCompress)
 This method will compress a given byte array dataToCompress using gzip. More...
 
static byte[] Compress (string stringToCompress, Encoding? encodingToUse=null)
 This method will compress a given string stringToCompress using the given encoding encodingToUse to compress a string to a byte array. More...
 
static byte[] Decompress (byte[] dataToDecompress)
 This method will decompress a given byte array dataToDecompress using gzip. More...
 
static string DecompressToString (byte[] dataToDecompress, Encoding? encodingToUse=null)
 This method will decompress a given byte array dataToDecompress to a string using the given encoding encodingToUse . More...
 

Detailed Description

Various utility functions for working with Gzip.

Member Function Documentation

◆ Compress() [1/2]

static byte [] Compress ( byte[]  dataToCompress)
inlinestatic

This method will compress a given byte array dataToCompress using gzip.

Parameters
dataToCompressThe byte array that will be compressed.
var myByteArray = new byte[] {1, 2, 3, 5, 6, 7 };
// Will return the compressed byte array
var myCompressedByteArray = Gzip.Compress(myByteArray);
Returns
The compressed byte array.

◆ Compress() [2/2]

static byte [] Compress ( string  stringToCompress,
Encoding?  encodingToUse = null 
)
inlinestatic

This method will compress a given string stringToCompress using the given encoding encodingToUse to compress a string to a byte array.

If no encoding encodingToUse it will use the default UTF8 encoding.

Parameters
stringToCompressString to compress.
encodingToUseEnconding to use for converting string to byte array.
var myString = "my string";
// Will return the compressed string as byte array, using ASCII for encoding
var myCompressedStringyASCII = Gzip.Compress(myString, Encoding.ASCII);
// Will return the compressed string as byte array, using UTF8 for encoding
var myCompressedStringUTF8 = Gzip.Compress(myString);
Returns
Compressed byte array.

◆ Decompress()

static byte [] Decompress ( byte[]  dataToDecompress)
inlinestatic

This method will decompress a given byte array dataToDecompress using gzip.

Parameters
dataToDecompressByte array to be decompressed.
var myCompressedByteArray = Gzip.Compress(new byte[] { 1, 2, 3, 5, 6, 7 });
// Will return the decompressed byte array
var myDecompressedByteArray = Gzip.Decompress(myCompressedByteArray);
Returns
The decompressed byte array.

◆ DecompressToString()

static string DecompressToString ( byte[]  dataToDecompress,
Encoding?  encodingToUse = null 
)
inlinestatic

This method will decompress a given byte array dataToDecompress to a string using the given encoding encodingToUse .

If no encoding encodingToUse it will use the default UTF8 encoding.

Parameters
dataToDecompressByte array to decompress.
encodingToUseEnconding to use for converting byte array to string.
var myString = "my string";
var myCompressedStringASCII = Gzip.Compress(myString, Encoding.ASCII);
var myCompressedStringUTF8 = Gzip.Compress(myString);
// Will return the decompressed string using the provided encoding
var myDecompressedStringASCII = Gzip.DecompressToString(myCompressedStringASCII, Encoding.ASCII);
// Will return the decompressed string using the default (UTF8) encoding
var myDecompressedStringUTF8 = Gzip.DecompressToString(myCompressedStringUTF8);
Returns
Decompressed string.

The documentation for this class was generated from the following file: