Various utility functions for working with Gzip.
More...
|
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...
|
|
Various utility functions for working with Gzip.
◆ Compress() [1/2]
static byte [] Compress |
( |
byte[] |
dataToCompress | ) |
|
|
inlinestatic |
This method will compress a given byte array dataToCompress using gzip.
- Parameters
-
dataToCompress | The byte array that will be compressed. |
var myByteArray = new byte[] {1, 2, 3, 5, 6, 7 };
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
-
stringToCompress | String to compress. |
encodingToUse | Enconding to use for converting string to byte array. |
var myString = "my string";
var myCompressedStringyASCII = Gzip.Compress(myString, Encoding.ASCII);
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
-
dataToDecompress | Byte array to be decompressed. |
var myCompressedByteArray = Gzip.Compress(new byte[] { 1, 2, 3, 5, 6, 7 });
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
-
dataToDecompress | Byte array to decompress. |
encodingToUse | Enconding to use for converting byte array to string. |
var myString = "my string";
var myCompressedStringASCII = Gzip.Compress(myString, Encoding.ASCII);
var myCompressedStringUTF8 = Gzip.Compress(myString);
var myDecompressedStringASCII = Gzip.DecompressToString(myCompressedStringASCII, Encoding.ASCII);
var myDecompressedStringUTF8 = Gzip.DecompressToString(myCompressedStringUTF8);
- Returns
- Decompressed string.
The documentation for this class was generated from the following file:
- Source/SCM.SwissArmyKnife/Compression/Gzip.cs