X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 70C304762FB for ; Sat, 10 May 2003 13:37:07 -0400 (EDT) Received: from randalls-laptop.kicks-ass.net (h00062577286a.ne.client2.attbi.com [24.61.43.102]) by postgresql.org (Postfix) with ESMTP id 548154762F6 for ; Sat, 10 May 2003 13:37:06 -0400 (EDT) Received: from tercent.net (localhost [127.0.0.1]) by randalls-laptop.kicks-ass.net (8.12.9/8.12.6) with ESMTP id h4AHamfd013712; Sat, 10 May 2003 13:36:58 -0400 (EDT) Date: Sat, 10 May 2003 13:36:47 -0400 Subject: Re: Using psql to insert character codes Content-Type: text/plain; charset=ISO-8859-1; format=flowed Mime-Version: 1.0 (Apple Message framework v552) Cc: pgsql-sql@postgresql.org To: Ian Barwick From: Randall Lucas In-Reply-To: <200305101853.20266.barwick@gmx.net> Message-Id: Content-Transfer-Encoding: quoted-printable X-Mailer: Apple Mail (2.552) X-Spam-Status: No, hits=-29.1 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REPLY_WITH_QUOTES,USER_AGENT_APPLEMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200305/195 X-Sequence-Number: 13360 Ah, I see. In that case, I would recommend=20 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 /=20 > 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)=20 > 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=20 > 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 '=E4' (lower=20 >>> 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) >