pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Randall Lucas <rlucas@tercent.net>
To: Ian Barwick <barwick@gmx.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: Using psql to insert character codes
Date: Sat, 10 May 2003 13:36:47 -0400
Message-ID: <F9B58582-830D-11D7-B164-000A957653D6@tercent.net> (raw)
In-Reply-To: <200305101853.20266.barwick@gmx.net>


Ah, I see.  </mac_over_enthusiasm>  In that case, I would recommend 
just making a custom function that handles that for you, maybe:

create function hex2esc(text) returns text as '
select encode(decode($1,''hex''), ''escape'');
' language sql;

Not a whole lot more elegant but shorter.

Best,

Randall

On Saturday, May 10, 2003, at 12:53 PM, Ian Barwick wrote:

> On Saturday 10 May 2003 18:15, Randall Lucas wrote:
>> Yes, use a Mac!
>>
>> I'm not being entirely facetious -- if you can use a Mac OS X terminal
>> prompt (and if your pg config is substantially similar to mine),
>> inserting any unicode stuff is quite easy.  Simply typing or
>> cutting-and-pasting at the terminal let me visually put in accented
>> Latin, Cyrillic, and Chinese (don't ask me what kind, I am a
>> sinoignoramus) no sweat.
>
> Thanks, but right answer to wrong question ;-). "mlterm" in Linux / 
> FreeBSD
> works fine for me; the "problem" is not inputting in general, but the
> ability to use psql to input using the hexadecimal (or decimal) 
> character
> code, which I need to do occasionally for some obscure character not
> reachable by other means.
>
> The solution I posted works, I was just wondering whether there was 
> some more
> elegant method I had overlooked.
>
> Ian Barwick
> barwick@gmx.net
>
>> On Saturday, May 10, 2003, at 10:20 AM, Ian Barwick wrote:
>>> Say using psql I wish to insert a character into a VARCHAR / TEXT /
>>> whatever
>>> column using the its hexadecimal representation in the relevant
>>> character set
>>> / encoding. E.g.: C3A4, which represents the character 'รค' (lower 
>>> case
>>> a with
>>> umlaut) in UTF-8.
>>>
>>> I can do this:
>>> INSERT INTO my_tbl (unitxt) VALUE(encode(decode('c3a4','hex'),
>>> 'escape'))
>>>
>>> Is there any other, shorter way of doing the same?
>>>
>>>
>>> Ian Barwick
>>> barwick@gmx.net
>>>
>>>
>>> ---------------------------(end of
>>> broadcast)---------------------------
>>> TIP 2: you can get off all lists at once with the unregister command
>>>     (send "unregister YourEmailAddressHere" to
>>> majordomo@postgresql.org)
>




view thread (8+ messages)  latest in thread

Message-ID: <F9B58582-830D-11D7-B164-000A957653D6@tercent.net>
Permalink:  ../F9B58582-830D-11D7-B164-000A957653D6@tercent.net/
Also on:    postgresql.org/message-id/F9B58582-830D-11D7-B164-000A957653D6@tercent.net

 · 

reply

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-sql@postgresql.org
  Cc: rlucas@tercent.net, barwick@gmx.net
  Subject: Re: Using psql to insert character codes
  In-Reply-To: <F9B58582-830D-11D7-B164-000A957653D6@tercent.net>
  References: <200305101853.20266.barwick@gmx.net> <F9B58582-830D-11D7-B164-000A957653D6@tercent.net>

* 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