Re: How can I insert a UTF-8 character with psql?

From: Roland Glenn McIntosh <roland(at)steeltorch(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: How can I insert a UTF-8 character with psql?
Date: 2003-06-13 13:57:47
Message-ID: 5.1.0.14.2.20030613093614.05e9af88@lnxmain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ian - Thank you very much for your reply. It only seems to half work, however.
This Euro sign is giving me a headache.
I tried both of the following:

UPDATE my_tbl SET value='\40\254' WHERE NAME LIKE 'curr%';
and
UPDATE my_tbl SET value=encode(decode('20ac','hex'), 'escape') WHERE NAME LIKE 'curr%';
and
UPDATE my_tbl SET value='\040\254' WHERE NAME LIKE 'curr%';

Note that the documentation states this:
"Anything contained in single quotes is furthermore subject to C-like
substitutions for \n (new line), \t (tab), \digits, \0digits, and \0xdigits
(the character with the given decimal, octal, or hexadecimal code)."

That appears to just be incorrect. Is there any form of this behavior that I can rely on in 7.3.3? Note that the "\254" part (AC in hex) appears to work correctly. As far as I can tell, hex value AC is getting inserted. It's the "20" part I'm having difficulty with.

Anyone have a solution for me?

-rgm

At 09:03 AM 06.13.2003 +0200, you wrote:
>On Friday 13 June 2003 00:13, Roland Glenn McIntosh wrote:
>> I would like to insert a EuroSign as two byte character number 20AC.
>> Is there a way I can do this from an ISO-8859-1 (latin1) terminal emulator
>> via the psql tool? Is there an entity scheme?
>>
>> I tried various permutations of the following to no avail:
>> INSERT INTO mytable VALUES('currency_symbol','\u20AC');
>
>Use escaped octal codes:
>INSERT INTO my_tbl (unitxt) VALUES('\303\244')
>(replace '\303\244' with whatever 20AC is in octal), or if you prefer typing
>to maths:
>
>INSERT INTO my_tbl (unitxt) VALUES(encode(decode('c3a4','hex'), 'escape'))
>
>Ian Barwick
>barwick(at)gmx(dot)net

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Mike Mascari 2003-06-13 14:20:48 Re: Insert NULL for ''
Previous Message Tom Lane 2003-06-13 13:55:12 Re: Insert NULL for ''