Perhaps my understanding of the 'encode' function is incorrect, but I was under the impression that I could do something like: SELECT lower(encode(bytes, 'escape')) FROM mytable; as it sounded like (from the manual) that 'encode' would return valid ASCII, with all the non-ascii bytes hex escaped. When I have the byte 0x8a, however, I get the error: ERROR: invalid byte sequence for encoding "UTF8": 0x8a I have the sneaking suspicion that I am missing something, so please correct me if I am wrong. If I am wrong, is there a better way to lowercase all the ascii characters in a bytea string? Here is a simple way to recreate this: CREATE TABLE mytable (bytes BYTEA); INSERT INTO mytable VALUES (E'212'); SELECT lower(encode(bytes, 'escape')) FROM mytable; Thanks -Mike