utils

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2025 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EndsWithNullTerminator added in v1.0.3

func EndsWithNullTerminator(input string) bool

EndsWithNullTerminator checks if the input string ends with a null terminator

Parameters: - input: The input string to check.

Returns: - A boolean indicating if the input string ends with a null terminator.

func EndsWithNullTerminatorUTF16 added in v1.0.3

func EndsWithNullTerminatorUTF16(input []byte) bool

EndsWithNullTerminatorUTF16 checks if the input byte slice ends with a null terminator

Parameters: - input: The input string to check.

Returns: - A boolean indicating if the input string ends with a null terminator.

func PadStringLeft

func PadStringLeft(input string, padChar string, length int) string

Example: PadStringLeft("hello", "*", 8) returns "***hello"

Note: The function adds a space to the input string before padding to ensure proper alignment.

func PadStringRight

func PadStringRight(input string, padChar string, length int) string

PadStringRight pads the input string with the specified padChar on the right side until the string reaches the specified length. If the input string is already longer than or equal to the specified length, it returns the input string as is.

Parameters: - input: The original string to be padded. - padChar: The character to pad the input string with. - length: The desired total length of the output string.

Returns: - A new string that is padded with padChar on the right side to the specified length.

Example: PadStringRight("hello", "*", 8) returns "hello***"

Note: The function adds a space to the input string before padding to ensure proper alignment.

func ReadUntilNullTerminator added in v1.0.3

func ReadUntilNullTerminator(data []byte) ([]byte, int)

ReadUntilNullTerminator reads bytes from a byte slice until it encounters a null byte and returns the data up to (but not including) the null byte.

Parameters: - data: The byte slice to read from

Returns: - A byte slice containing the data up to the first null byte - The number of bytes read (including the null byte)

func ReadUntilNullTerminatorUTF16 added in v1.0.3

func ReadUntilNullTerminatorUTF16(data []byte) ([]byte, int)

ReadUntilNullTerminatorUTF16 reads bytes from a byte slice until it encounters a UTF-16 null terminator and returns the data up to (but not including) the null terminator.

Parameters: - data: The byte slice to read from

Returns: - A byte slice containing the data up to the first null terminator - The number of bytes read (including the null terminator)

func SizeInBytes

func SizeInBytes(size uint64) string

SizeInBytes converts a size in bytes to a human-readable string representation using binary prefixes (KiB, MiB, GiB).

Parameters: - size: The size in bytes to be converted.

Returns: - A string representing the size in a human-readable format with binary prefixes.

Example: SizeInBytes(1048576) returns "1.00 MiB"

Note: The function uses binary prefixes where 1 KiB = 1024 bytes, 1 MiB = 1024 KiB, and 1 GiB = 1024 MiB.

Types

This section is empty.

Directories

Path Synopsis
encoding

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL