Documentation
¶
Index ¶
- func EndsWithNullTerminator(input string) bool
- func EndsWithNullTerminatorUTF16(input []byte) bool
- func PadStringLeft(input string, padChar string, length int) string
- func PadStringRight(input string, padChar string, length int) string
- func ReadUntilNullTerminator(data []byte) ([]byte, int)
- func ReadUntilNullTerminatorUTF16(data []byte) ([]byte, int)
- func SizeInBytes(size uint64) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EndsWithNullTerminator ¶ added in v1.0.3
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
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 ¶
Example: PadStringLeft("hello", "*", 8) returns "***hello"
Note: The function adds a space to the input string before padding to ensure proper alignment.
func PadStringRight ¶
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
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
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 ¶
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.