From: Andrew Gierth <andrew@tao11.riddles.org.uk>
To: Matthias Apitz <guru@unixarea.de>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: SELECT d02name::bytea FROM ... && DBI::Pg
Date: Sat, 12 Oct 2019 19:51:57 +0100
Message-ID: <87zhi5vm0z.fsf@news-spur.riddles.org.uk> (raw)
In-Reply-To: <20191010112458.GA271079@sh4-5.1blu.de>
References: <20191010112458.GA271079@sh4-5.1blu.de>
>>>>> "Matthias" == Matthias Apitz <guru@unixarea.de> writes:
Matthias> Hello,
Matthias> I can SELECT && print a column in hex with:
Matthias> pos71=# select d02name::bytea from d02ben where d02bnr = '00001048313' ;
If your intention is to see the raw bytes of the stored text value, for
example to check the encoding, then you should not do it that way.
Casting from text to bytea does NOT do what you think.
Instead use convert_to(d02name,'SQL_ASCII') (yes, always specify
SQL_ASCII regardless of what encoding you think it should be in, since
the actual meaning of SQL_ASCII is "no conversions"). For readability,
you may then want to wrap that as
encode(convert_to(d02name,'SQL_ASCII'),'escape') which will keep the
ASCII characters but use \nnn escapes for non-ascii.
--
Andrew (irc:RhodiumToad)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: andrew@tao11.riddles.org.uk, guru@unixarea.de
Subject: Re: SELECT d02name::bytea FROM ... && DBI::Pg
In-Reply-To: <87zhi5vm0z.fsf@news-spur.riddles.org.uk>
References: <20191010112458.GA271079@sh4-5.1blu.de> <87zhi5vm0z.fsf@news-spur.riddles.org.uk>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox