Escaped strings [1] fail on hex values greater than \x7f with a factually incorrect error message:
$ psql --command "select E'\x80';"
ERROR: invalid byte sequence for encoding "UTF8": 0x80
$ psql --version
psql (PostgreSQL) 13.1
I was able to reproduce this bug on psql 10.
Workaround:
$ psql --command "select E'\u0080';"
?column?
----------
\u0080
(1 row)
1: https://www.postgresql.org/docs/13/sql-syntax-lexical.html#id-1.5.3.5.9.5.3