encode, lower and 0x8a - Mailing list pgsql-general

From Michael Artz
Subject encode, lower and 0x8a
Date
Msg-id e9c163070701251128i318fa118s5d3d32744082f2d3@mail.gmail.com
Whole thread Raw
Responses Re: encode, lower and 0x8a
List pgsql-general
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

pgsql-general by date:

Previous
From: "Jeremy Haile"
Date:
Subject: Re: Stats collector frozen?
Next
From: Bruce Momjian
Date:
Subject: Re: sequence increment jumps?