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

Function encodeASCIIString

par2/string.go:41–50  ·  view source on GitHub ↗
(s string)

Source from the content-addressed store, hash-verified

39}
40
41func encodeASCIIString(s string) ([]byte, error) {
42 var bs []byte
43 for _, c := range s {
44 if c > unicode.MaxASCII {
45 return nil, errors.New("invalid ASCII character")
46 }
47 bs = append(bs, byte(c))
48 }
49 return bs, nil
50}

Callers 4

TestEncodeASCIIStringFunction · 0.85
TestEncodeNonASCIIStringFunction · 0.85
writeCreatorPacketFunction · 0.85

Calls

no outgoing calls

Tested by 2

TestEncodeASCIIStringFunction · 0.68
TestEncodeNonASCIIStringFunction · 0.68