Re: convert very large unsigned numbers to base62? - Mailing list pgsql-general

From Greg Smith
Subject Re: convert very large unsigned numbers to base62?
Date
Msg-id Pine.GSO.4.64.0805142143590.27290@westnet.com
Whole thread Raw
In response to Re: convert very large unsigned numbers to base62?  ("D. Dante Lorenso" <dante@lorenso.com>)
List pgsql-general
On Wed, 14 May 2008, D. Dante Lorenso wrote:

> Stuart Cooper wrote:
>> base 62 is cruel and unusual punishment. Introduce two more printing
>> characters to your set a..z, A..Z, 0..9 such as "_" and "!" and do it in
>> base 64
>> instead.
>
> I thought about adding 2 more characters, but I didn't like anything that was
> on my keyboard

You really should use as much of an existing wheel here as possible rather
than completely reinventing one:

http://en.wikipedia.org/wiki/Base64

The standard additional two characters to add are "+/".

> My original question is more along the lines of trying to see if there
> were built-in functions in PostgreSQL that already do this type of base
> conversion.

http://www.postgresql.org/docs/current/static/functions-string.html shows
an encode and decode pair that can use base64, you may be able to leverage
those here.

--
* Greg Smith gsmith@gregsmith.com http://www.gregsmith.com Baltimore, MD

pgsql-general by date:

Previous
From: "D. Dante Lorenso"
Date:
Subject: Re: convert very large unsigned numbers to base62?
Next
From: "Eliot, Christopher"
Date:
Subject: Populating a sparse array piecemeal in plpgsql