Re: Convert from hex to string - Mailing list pgsql-general

From Adrian Klaver
Subject Re: Convert from hex to string
Date
Msg-id 5655E11E.70304@aklaver.com
Whole thread Raw
In response to Convert from hex to string  (Yuriy Rusinov <yrusinov@gmail.com>)
List pgsql-general
On 11/25/2015 07:47 AM, Yuriy Rusinov wrote:
> Hello, Colleagues !
>
> I have to transform string, encoded to hexadecimal to text, but if I try to
> select encode('Qt is great!', 'hex'); I receive valid and correct results
>
> 517420697320677265617421
>
> but if I try to select decode ('517420697320677265617421', 'hex'), I
> receive the same string, such as
> '\x517420697320677265617421, which way I have to do for valid convert
> to/from hexadecimal ?

aklaver@test=> select encode('Qt is great!', 'hex');
           encode
--------------------------
  517420697320677265617421
(1 row)

aklaver@test=> select decode ('517420697320677265617421', 'hex');
            decode
----------------------------
  \x517420697320677265617421
(1 row)


aklaver@test=> select convert_from('\x517420697320677265617421', 'UTF8');
  convert_from
--------------
  Qt is great!
(1 row)


>
> Thanks for attention.
>


--
Adrian Klaver
adrian.klaver@aklaver.com


pgsql-general by date:

Previous
From: Yuriy Rusinov
Date:
Subject: Convert from hex to string
Next
From: Francisco Olarte
Date:
Subject: Re: Convert from hex to string