Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 683489FA252 for ; Mon, 27 Nov 2006 11:50:45 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 98702-03 for ; Mon, 27 Nov 2006 11:50:33 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from mx3.ipf.is (man.ipf.is [85.197.192.163]) by postgresql.org (Postfix) with ESMTP id 3FE3A9FB1CE for ; Mon, 27 Nov 2006 11:50:33 -0400 (AST) Received: (qmail 12942 invoked by uid 1010); 27 Nov 2006 15:45:12 +0000 Received: from 88.149.106.19 by man (envelope-from , uid 1008) with qmail-scanner-1.25-st-qms (clamdscan: 0.88.4/1639. spamassassin: 3.1.4. perlscan: 1.25-st-qms. Clear:RC:1(88.149.106.19):SA:0(-2.5/4.5):. Processed in 4.200082 secs); 27 Nov 2006 15:45:12 -0000 X-Antivirus-HIVE-Mail-From: gnari@hive.is via man X-Antivirus-HIVE: 1.25-st-qms (Clear:RC:1(88.149.106.19):SA:0(-2.5/4.5):. Processed in 4.200082 secs Process 12923) Received: from dsl-149-106-19.hive.is (HELO ?192.168.1.33?) (88.149.106.19) by mx3.ipf.is with SMTP; 27 Nov 2006 15:45:07 +0000 Subject: Re: UNICODE and PL/PGSQL From: Ragnar To: Bart Degryse Cc: pgsql-sql@postgresql.org In-Reply-To: <456B0A47020000300000FC1E@webaccess.indicator.be> References: <456AD17A020000300000FB60@webaccess.indicator.be> <1164638251.270 70.45.camel@localhost.localdomain> <456B0A47020000300000FC1E@webaccess.indicator.be> Content-Type: text/plain; charset=ISO-8859-1 Date: Mon, 27 Nov 2006 15:57:10 +0000 Message-Id: <1164643030.27070.55.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.4.1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200611/260 X-Sequence-Number: 26912 On mán, 2006-11-27 at 15:54 +0100, Bart Degryse wrote: > Hi gnari, > I suppose your statement > test=# select '\x'||'65'; > is done on some command line interface. I don't have that. I can only > use some client program. I'm using EMS SQL Manager 2007 and pgAdmin > III 1.3 > None of them accepts your statement. > My point is that in my first version of the function ( charset := > charset || '\x65'; ) a unicode hex value for the letter e is stored > in charset. my point was that '\x65' as a literal is read as 'e', but '\\x' || '65' is just the concatation of 2 2-char varchars > When I try to do the same for a range of hex values ( FOR i IN > 101..101 LOOP charset := charset || '\x' || to_hex(i); ) you might be able to do what you want with set_byte() and encode(). CREATE OR REPLACE FUNCTION myfunction() RETURNS varchar AS $x$ DECLARE x bytea := ' '; BEGIN FOR i in 101..105 LOOP x:=set_byte(x,i-101,i); END LOOP; RETURN encode(x,''escape''); END; $x$ LANGUAGE 'plpgsql'; select myfunction(); gnari