Skip to content

Commit b7e471c

Browse files
Added StringToUnicodeByteArray
1 parent cb66fad commit b7e471c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

transform/encode.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,21 @@ import (
99
"slices"
1010
"strconv"
1111
"strings"
12+
"unicode/utf16"
1213

1314
"github.com/vulncheck-oss/go-exploit/output"
1415
"golang.org/x/text/cases"
1516
"golang.org/x/text/language"
1617
)
1718

19+
func StringToUnicodeByteArray(s string) []byte {
20+
var byteArray []byte
21+
for _, r := range utf16.Encode([]rune(s)) {
22+
byteArray = append(byteArray, byte(r&0xFF), byte(r>>8&0xFF))
23+
}
24+
return byteArray
25+
}
26+
1827
// Given gzip encoded data, return the decompressed data.
1928
func Inflate(compressed []byte) ([]byte, bool) {
2029
reader, err := gzip.NewReader(bytes.NewBuffer(compressed))

0 commit comments

Comments
 (0)