MCPcopy Create free account
hub / github.com/dolthub/doltgresql / DecodeRawBytesToByteArrayAuto

Function DecodeRawBytesToByteArrayAuto

postgres/parser/lex/encode.go:358–363  ·  view source on GitHub ↗

DecodeRawBytesToByteArrayAuto detects which format to use with DecodeRawBytesToByteArray(). It only supports hex ("\x" prefix) and escape.

(data []byte)

Source from the content-addressed store, hash-verified

356// DecodeRawBytesToByteArray(). It only supports hex ("\x" prefix)
357// and escape.
358func DecodeRawBytesToByteArrayAuto(data []byte) ([]byte, error) {
359 if len(data) >= 2 && data[0] == '\\' && (data[1] == 'x' || data[1] == 'X') {
360 return DecodeRawBytesToByteArray(string(data[2:]), BytesEncodeHex)
361 }
362 return DecodeRawBytesToByteArray(string(data), BytesEncodeEscape)
363}
364
365// BytesEncodeFormat controls which format to use for BYTES->STRING
366// conversions.

Callers 1

ParseDByteFunction · 0.92

Calls 1

Tested by

no test coverage detected