Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r4p7z-00AOJ8-2K for pgsql-general@arkaria.postgresql.org; Sun, 19 Nov 2023 21:14:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1r4p7x-004lpx-OB for pgsql-general@arkaria.postgresql.org; Sun, 19 Nov 2023 21:14:49 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r4oYE-004hcS-MI for pgsql-general@lists.postgresql.org; Sun, 19 Nov 2023 20:37:54 +0000 Received: from mailtransmit05.runbox.com ([2a0c:5a00:149::26]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r4oY8-007IbW-5i for pgsql-general@postgresql.org; Sun, 19 Nov 2023 20:37:53 +0000 Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1r4oY5-00Agr5-Ul for pgsql-general@postgresql.org; Sun, 19 Nov 2023 21:37:45 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=diorite.uk; s=selector1; h=Message-Id:Date:Subject:To:From:MIME-Version: Content-Transfer-Encoding:Content-Type; bh=U20EcQbby3DNzRM5yfGGq+pLfuE9hh/NjqESsdGKTfM=; b=aejpScUKGbrXjfDxd7GUCHU1DA AQ/orWR2Kiu/Od8X01lZhvrr/Mrl7IQbnfB9CR1MQ61ev6ZbsXhmDb2E6+5cAYjmisgNM2Dd+mJ6C jPHdoe5BQos/NFmgNx2lSE9h6UUPJAZXjWtMSMyH53fVxynwmXQS/HLww/blpgPh+ZbvVr3zjZuf9 ZQRnzoQzfGwtW4d2sObZLiFgWLmnslduQQR0zu+qWPl+4Gjv3Pp+ATxAXSrA8QqznF/uzQhLDV++l cNvzD3Zy4oqyShdOd1fHm5+woVUJFcg9epfs/figuopdfB1SGe0ZdSQx2aNU8pFXTNtIsoQB5wY17 Q41+g6Xw==; Received: from [10.9.9.128] (helo=rmmprod06.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1r4oY5-0002dn-5o for pgsql-general@postgresql.org; Sun, 19 Nov 2023 21:37:45 +0100 Received: from mail by rmmprod06.runbox with local (Exim 4.86_2) (envelope-from ) id 1r4oY5-00060N-4c for pgsql-general@postgresql.org; Sun, 19 Nov 2023 21:37:45 +0100 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Received: from [Authenticated alias (1182204)] by runbox.com with http (RMM6); for ; Sun, 19 Nov 2023 20:37:45 GMT From: "PGUser2020" To: "pgsql-general" Subject: How can I return a UTF8 string from a hex representation in a latin9 database? Date: Sun, 19 Nov 2023 20:37:45 +0000 (GMT) X-RMM-Aliasid: 1182204 X-Mailer: RMM6 Message-Id: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello. Hopefully I can explain myself I have a database for a legacy application that requires an 8 bit database = (i.e. the application itself won't function on a UTF8 database). Looking at ways to extend the functionality to be able to handle a few spec= ified fields in Unicode. Had the idea to store a UTF8 string as either hex pairs or Base64 inside a = VARCHAR field, which is fine. I can do that. What needs to happen though, is to build a view, that will return the decod= ed hex (or b64) as a UTF8 string to a client which has specified client enc= oding UTF8. I've tried various combinations of convert_from, and convert_to, and conve= rt, but I just can't seem to get it to return the string a UTF8 select to t= he client. So if I have this data: select * from mytable; mycolumn=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ------------------------------------------ ceb120ceb220ceb320ceb420ceb520cf83cf84=20=20 Then: select convert_from(decode(mycolumn, 'hex')::bytea, 'utf-8') from mytable w= here usr=3D'BATCH'; ERROR: character with byte sequence 0xce 0xb1 in encoding "UTF8" has no eq= uivalent in encoding "LATIN9" So the database encoding is still relevant , this is expected by the descri= ption of convert_from in the documentation of course. Is there some combination of functions I can use to have a client select th= is column from this table in a LATIN9 database and get a UTF8 string back? = Any thoughts appreciated, thank you.=