MCPcopy
hub / github.com/spicetify/cli / encodeUTF16LE

Function encodeUTF16LE

src/utils/file-utils.go:63–71  ·  view source on GitHub ↗

Helper function to encode a byte slice (assumed UTF-8) to UTF-16LE

(data []byte)

Source from the content-addressed store, hash-verified

61
62// Helper function to encode a byte slice (assumed UTF-8) to UTF-16LE
63func encodeUTF16LE(data []byte) []byte {
64 utf16Bytes := utf16.Encode([]rune(string(data)))
65 byteSlice := make([]byte, len(utf16Bytes)*2)
66 for i, r := range utf16Bytes {
67 binary.LittleEndian.PutUint16(byteSlice[i*2:], r)
68 }
69
70 return byteSlice
71}
72
73// Helper function to decode a byte slice (UTF-16LE) to UTF-8
74func decodeUTF16LE(data []byte) ([]byte, error) {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected