Documentation
¶
Overview ¶
Package bytesconv facilitates the interpretation of raw bytes as strings.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidUTF16 is returned when the provided bytes are not valid // UTF-16. ErrInvalidUTF16 = errors.New("the UTF-16 data is invalid") // ErrUnevenUTF16 is returned when the provided bytes are not an even // length. The UTF-16 encoding requires an even number of bytes. ErrUnevenUTF16 = errors.New("the UTF-16 data is not an even length") )
Functions ¶
func DecodeString ¶
DecodeString attempts to interpret the given bytes as a string. If the bytes are valid UTF-8, they are returned as a string without modification.
If the bytes are not valid UTF-8, it attempts to interpret them as UTF-16. If successful, it converts the bytes to UTF-8 and returns the resulting string.
If a unicode encoding is not detected, or conversion to a string is not successful, it returns the bytes as a Base64 raw URL-encoded string.
func DecodeUTF16 ¶
DecodeUTF16 interprets the given bytes as UTF-16 with the specified byte order and returns the value as a string.
Any invalid characters will be replaced with the unicode replacement character.
func HasUTF16BOM ¶
HasUTF16BOM returns true if the given bytes have a unicode byte order mark with the specified byte order.
Types ¶
This section is empty.