encode, lower and 0x8a

From: "Michael Artz" <mlartz(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: encode, lower and 0x8a
Date: 2007-01-25 19:28:38
Message-ID: e9c163070701251128i318fa118s5d3d32744082f2d3@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2007-01-25 19:34:40 Re: sequence increment jumps?
Previous Message Douglas McNaught 2007-01-25 19:22:11 Re: sequence increment jumps?