converting text to bytea

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

converting text to bytea

Yambu
Hello

This sounds simple, but im not getting the results when i cast text to bytea like this first_name::bytea . Is there another way to do this?

regards
Reply | Threaded
Open this post in threaded view
|

Re: converting text to bytea

Pavel Stehule
Hi

po 22. 2. 2021 v 7:37 odesílatel Yambu <[hidden email]> napsal:
Hello

This sounds simple, but im not getting the results when i cast text to bytea like this first_name::bytea . Is there another way to do this?

You should to use convert_to function


Regards

Pavel


regards
Reply | Threaded
Open this post in threaded view
|

Re: converting text to bytea

Yambu
Hi

Is there a reason why i'm getting text when i run the below

select convert_to('some_text', 'UTF8')    i get back 'some_text' 

regards

On Mon, Feb 22, 2021 at 9:09 AM Pavel Stehule <[hidden email]> wrote:
Hi

po 22. 2. 2021 v 7:37 odesílatel Yambu <[hidden email]> napsal:
Hello

This sounds simple, but im not getting the results when i cast text to bytea like this first_name::bytea . Is there another way to do this?

You should to use convert_to function


Regards

Pavel


regards
Reply | Threaded
Open this post in threaded view
|

Re: converting text to bytea

Tom Lane-2
Yambu <[hidden email]> writes:
> Is there a reason why i'm getting text when i run the below
> select convert_to('some_text', 'UTF8')    i get back 'some_text'

You must have bytea_output set to "escape".

                        regards, tom lane


Reply | Threaded
Open this post in threaded view
|

Re: converting text to bytea

Pavel Stehule


čt 25. 2. 2021 v 16:01 odesílatel Tom Lane <[hidden email]> napsal:
Yambu <[hidden email]> writes:
> Is there a reason why i'm getting text when i run the below
> select convert_to('some_text', 'UTF8')    i get back 'some_text'

You must have bytea_output set to "escape".


yes

set bytea_output TO escape ;
postgres=# select convert_to('žlutý kůň', 'UTF8') ;
┌───────────────────────────────────────┐
│              convert_to               │
╞═══════════════════════════════════════╡
│ \305\276lut\303\275 k\305\257\305\210 │
└───────────────────────────────────────┘
(1 row)


                        regards, tom lane