github.com/trim21/go-phpserialize@v0.0.22-0.20240301204449-2fca0319b3f0/internal/encoder/common.go (about) 1 package encoder 2 3 import "strconv" 4 5 func appendEmptyArray(b []byte) []byte { 6 return append(b, "a:0:{}"...) 7 } 8 9 func appendNull(b []byte) []byte { 10 return append(b, 'N', ';') 11 } 12 13 func appendStringHead(b []byte, length int64) []byte { 14 b = append(b, 's', ':') 15 b = strconv.AppendInt(b, length, 10) 16 return append(b, ':') 17 } 18 19 func appendArrayBegin(b []byte, fieldNum int64) []byte { 20 b = append(b, 'a', ':') 21 b = strconv.AppendInt(b, fieldNum, 10) 22 return append(b, ':', '{') 23 } 24 25 func appendBytesAsPhpStringVariable(dst, src []byte) []byte { 26 dst = append(dst, 's', ':', '"') 27 dst = strconv.AppendInt(dst, int64(len(src)), 10) 28 return append(dst, '"', ':') 29 }