MCPcopy Create free account
hub / github.com/akalin/gopar / decodeUTF16LEString

Function decodeUTF16LEString

par1/file_entry.go:67–83  ·  view source on GitHub ↗
(bs []byte)

Source from the content-addressed store, hash-verified

65}
66
67func decodeUTF16LEString(bs []byte) string {
68 u16s := make([]uint16, len(bs)/2)
69 for i := 0; i < len(u16s); i++ {
70 u16s[i] = uint16(bs[2*i]) + uint16(bs[2*i+1])<<8
71 }
72
73 runes := utf16.Decode(u16s)
74
75 var runeBuf [4]byte
76 var buf bytes.Buffer
77 for i := 0; i < len(runes); i++ {
78 n := utf8.EncodeRune(runeBuf[:], runes[i])
79 buf.Write(runeBuf[:n])
80 }
81
82 return buf.String()
83}
84
85func encodeUTF16LEString(s string) []byte {
86 var runes []rune

Callers 2

readFileEntryFunction · 0.85

Calls 2

WriteMethod · 0.45
StringMethod · 0.45

Tested by 1