bytea to varchar using different charsets

From: Peter Bauer <peter(dot)bauer(at)apus(dot)co(dot)at>
To: pgsql-general(at)postgresql(dot)org
Subject: bytea to varchar using different charsets
Date: 2008-01-29 09:13:01
Message-ID: 200801291013.01390.peter.bauer@apus.co.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Hi all,

i would like to write a PL/PGSQL function to convert a bytea into a varchar
using the character maps GSM 03.38
(http://en.wikipedia.org/wiki/Short_message_service) and ISO 8859-1
(http://en.wikipedia.org/wiki/Iso_8859-1#ISO-8859-1)
The first approach would be to loop through the bytes and map each of them to
a character and thus build up the string. The question is if there already
exists such a functionality or how the mapping could be done in an elegant
way. What i found was
convert(string using conversion_name) from
http://www.postgresql.org/docs/8.2/static/functions-string.html with the
various Built-in Conversions and
chr(int) which is only available for the ASCII charset.

thx,
Peter

--
Peter Bauer
APUS Software G.m.b.H.
A-8074 Raaba, Bahnhofstrasse 1/1
Email: peter(dot)bauer(at)apus(dot)co(dot)at
Tel: +43 316 401629 24
Fax: +43 316 401629 9

Browse pgsql-general by date

  From Date Subject
Next Message Raymond O'Donnell 2008-01-29 10:57:38 Re: using = in a function
Previous Message Håkan Jacobsson 2008-01-29 09:06:19 Re: Getting the count(*) from two tables and two date ranges in same query