DecodeRawBytesToByteArrayAuto detects which format to use with DecodeRawBytesToByteArray(). It only supports hex ("\x" prefix) and escape.
(data []byte)
| 356 | // DecodeRawBytesToByteArray(). It only supports hex ("\x" prefix) |
| 357 | // and escape. |
| 358 | func 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. |
no test coverage detected