Good day.
AFAIK PostgreSQL provides the type TEXT with 4-byte prefix length
which is distinct to C's zero-terminated (char *)
That's very good.
Then I expect natural possibility to store texts having zero characters.
try
SELECT 'abc\0de';
SELECT length('abc\0de');
or insert such a value into another table and then select....
you'll see a classical result just like you are using (char *).
i suppose it is a little bug deep inside like using a memcpy() or such...
Am i wrong?