github.com/trim21/go-phpserialize@v0.0.22-0.20240301204449-2fca0319b3f0/internal/encoder/uint.go (about) 1 package encoder 2 3 import ( 4 "strconv" 5 "unsafe" 6 ) 7 8 func encodeUint8(ctx *Ctx, b []byte, p uintptr) ([]byte, error) { 9 value := **(**uint8)(unsafe.Pointer(&p)) 10 b = append(b, 'i', ':') 11 b = strconv.AppendUint(b, uint64(value), 10) 12 return append(b, ';'), nil 13 } 14 15 func encodeUint16(ctx *Ctx, b []byte, p uintptr) ([]byte, error) { 16 value := **(**uint16)(unsafe.Pointer(&p)) 17 b = append(b, 'i', ':') 18 b = strconv.AppendUint(b, uint64(value), 10) 19 return append(b, ';'), nil 20 } 21 22 func encodeUint32(ctx *Ctx, b []byte, p uintptr) ([]byte, error) { 23 value := **(**uint32)(unsafe.Pointer(&p)) 24 b = append(b, 'i', ':') 25 b = strconv.AppendUint(b, uint64(value), 10) 26 return append(b, ';'), nil 27 } 28 29 func encodeUint64(ctx *Ctx, b []byte, p uintptr) ([]byte, error) { 30 value := **(**uint64)(unsafe.Pointer(&p)) 31 b = append(b, 'i', ':') 32 b = strconv.AppendUint(b, uint64(value), 10) 33 return append(b, ';'), nil 34 } 35 36 func encodeUint(ctx *Ctx, b []byte, p uintptr) ([]byte, error) { 37 value := **(**uint)(unsafe.Pointer(&p)) 38 b = append(b, 'i', ':') 39 b = strconv.AppendUint(b, uint64(value), 10) 40 return append(b, ';'), nil 41 }