invalid byte sequence for encoding “UTF8″: 0×8b – storing binary data

This error message took me lots of effort and time to solve it. The problem is that before storing binary data strings in the postgresql database the binary strings need to be escaped before storing them. There is on the google available subroutine for per which is doing this job. It is called escape_bytea. Anyway [...]