I'd like to propose a carray_to_bytea function, similar to cstring_to_text_with_len, declared in src/include/utils.h and implemented in src/backend/utils/adt/varlena.c. The implementation would be the same as cstring_to_text_with_len, but with a different return type.
I have put the implementation in my code, but I'd much prefer to use a public API with hidden implementation.