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

Function nullTerminate

par2/string.go:9–19  ·  view source on GitHub ↗
(bs []byte)

Source from the content-addressed store, hash-verified

7)
8
9func nullTerminate(bs []byte) []byte {
10 // This emulates the direction in the spec to append a null
11 // byte to turn a string into a null-terminated one.
12 for i, b := range bs {
13 if b == '\x00' {
14 return bs[:i]
15 }
16 }
17
18 return bs
19}
20
21func decodeNullPaddedASCIIString(bs []byte) string {
22 // First, null-terminate if necessary.

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected