From: | Ian Barwick <barwick(at)gmail(dot)com> |
---|---|
To: | Alban Hertroys <alban(at)magproductions(dot)nl> |
Cc: | Postgres general mailing list <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: How to manually insert an UTF-8 character into an SQL statement? |
Date: | 2005-01-20 22:45:28 |
Message-ID: | 1d581afe0501201445ae016b5@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Thu, 20 Jan 2005 14:48:40 +0100, Alban Hertroys
<alban(at)magproductions(dot)nl> wrote:
> I'm trying to insert a record that contains an ô (o circumflex) into a
> table using the psql client.
> I also tried with phppgadmin and pgadmin, but both can't do this. They
> insert a HTML entity and error out respectively. Not what I had in mind...
>
> Supposedly I should be able to type:
> INSERT INTO table (name) VALUES ('C\0x00f4te d''Azur');
> but all I manage to achieve is inserting a capital 'C'...
>
> It doesn't seem to matter to which encoding I set psql either.
> What am I doing wrong?
For a start, 0x00F4 does not represent valid UTF-8; you want 0xC3B4.
AFAIK you can insert this using two different methods in psql:
\set myvalue '\'C\0xc3\0xb4te d\'\'Azur\''
INSERT INTO table (name) VALUES (:myvalue);
in 8.0 also:
\set myvalue '$$C\0xc3\0xb4te d\'Azur$$'
or:
INSERT INTO table (name) values
('C'||encode(decode('c3b4','hex'),'escape')||'te d''Azur');
Ian Barwick
From | Date | Subject | |
---|---|---|---|
Next Message | Josué Maldonado | 2005-01-20 22:49:56 | Data format and display |
Previous Message | Richard Huxton | 2005-01-20 21:06:15 | Re: Client's variables |