Helper function to encode a byte slice (assumed UTF-8) to UTF-16LE
(data []byte)
| 61 | |
| 62 | // Helper function to encode a byte slice (assumed UTF-8) to UTF-16LE |
| 63 | func 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 |
| 74 | func decodeUTF16LE(data []byte) ([]byte, error) { |
no outgoing calls
no test coverage detected