Skip to content
Taiizor edited this page Mar 1, 2023 · 7 revisions

Encode Class - Skylark.Helper Namespace

The Encode class provides methods to convert text to bytes and bytes to text using various encoding types.

Methods

GetBytes

public static byte[] GetBytes(string Text, SEET Encode)

Converts the specified string to an array of bytes using the specified encoding type.

Parameters

  • Text: The string to convert to a byte array.
  • Encode: The encoding type to use for the conversion.

Returns

The byte array representation of the input string.

Exceptions

  • SE: If the encoding type is not a defined value in the SEET enum.

GetString

public static string GetString(byte[] Bytes, SEET Encode)

Converts the specified byte array to a string using the specified encoding type.

Parameters

  • Bytes: The byte array to convert to a string.
  • Encode: The encoding type to use for the conversion.

Returns

The string representation of the input byte array.

Exceptions

  • SE: If the encoding type is not a defined value in the SEET enum.

Enums

EncodeType (SEET)

An enumeration of supported encoding types.

public enum EncodeType
{
    UTF7,
    UTF8,
    UTF32,
    ASCII,
    Unicode,
    Default,
    BigEndianUnicode
}

Exceptions

SE (Skylark.Exception)

Represents an exception that is thrown when an encoding type is not a defined value in the SEET enum.

Static Members

ErrorMessage (private const string)

A constant string that contains the error message to use when an invalid encoding type is specified.

GetEncoding (private extension method)

private static Encoding GetEncoding(this SEET EncodeType, bool UseUtf8IfNotValid = false, string ErrorMessage = ErrorMessage)

Retrieves the Encoding object for the specified encoding type.

Parameters

  • EncodeType: The encoding type to retrieve the Encoding object for.
  • UseUtf8IfNotValid: A flag indicating whether to use UTF-8 encoding if the specified encoding type is not valid.
  • ErrorMessage: The error message to use if the specified encoding type is not valid.

Returns

The Encoding object for the specified encoding type.

Exceptions

  • SE: If the encoding type is not a defined value in the SEET enum and UseUtf8IfNotValid is false.
Clone this wiki locally