Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeUTF16LE ¶
DecodeUTF16LE decodes UTF-16 little endian bytes to a string
This function takes a byte slice and decodes it to a string. It creates a slice of uint16 values with half the length of the byte slice, and fills it with the UTF-16 little endian decoded values. Then, it uses the utf16.Decode function to convert the uint16 slice to a string.
Returns:
- A string representing the UTF-16 little endian decoded byte slice.
func EncodeUTF16LE ¶
EncodeUTF16LE encodes a string to UTF-16 little endian bytes
This function takes a string and encodes it to UTF-16 little endian bytes. It uses the utf16.Encode function to convert the string to a slice of uint16 values. Then, it creates a byte slice with twice the length of the utf16le slice, and fills it with the UTF-16 little endian encoded values.
Returns:
- A byte slice representing the UTF-16 little endian encoded string.
func IsUTF16LE ¶ added in v1.0.3
IsUTF16LE checks if a byte slice is valid UTF-16LE encoded data
This function takes a byte slice and checks if it represents valid UTF-16LE encoded data. It verifies that: 1. The length is even (UTF-16 uses 2 bytes per code unit) 2. Each code unit has 0x00 in the high byte, indicating ASCII range characters
Note: This is a simplified check that only validates ASCII range characters. For full UTF-16LE validation, surrogate pairs and non-ASCII characters would need to be handled.
Returns:
- true if the byte slice appears to be valid UTF-16LE ASCII text
- false otherwise
Types ¶
This section is empty.