MCPcopy Index your code
hub / github.com/aarondl/sqlboiler / encodeBytea

Function encodeBytea

types/array.go:134–155  ·  view source on GitHub ↗
(serverVersion int, v []byte)

Source from the content-addressed store, hash-verified

132}
133
134func encodeBytea(serverVersion int, v []byte) (result []byte) {
135 if serverVersion >= 90000 {
136 // Use the hex format if we know that the server supports it
137 result = make([]byte, 2+hex.EncodedLen(len(v)))
138 result[0] = '\\'
139 result[1] = 'x'
140 hex.Encode(result[2:], v)
141 } else {
142 // .. or resort to "escape"
143 for _, b := range v {
144 if b == '\\' {
145 result = append(result, '\\', '\\')
146 } else if b < 0x20 || b > 0x7e {
147 result = append(result, []byte(fmt.Sprintf("\\%03o", b))...)
148 } else {
149 result = append(result, b)
150 }
151 }
152 }
153
154 return result
155}
156
157var errInvalidTimestamp = errors.New("invalid timestamp")
158

Callers 1

encodeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…