From: Tom Lane <tgl@sss.pgh.pa.us>
To: Bob Jolliffe <bobjolliffe@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: casting Bangla characters to NUMERIC
Date: Mon, 25 Nov 2019 11:27:40 -0500
Message-ID: <3579.1574699260@sss.pgh.pa.us> (raw)
In-Reply-To: <CACd=f9e+D_m=hTm9fV-hoMG4CDjo6qw0Z4Uk3peUhCOR=O+caA@mail.gmail.com>
References: <CACd=f9e+D_m=hTm9fV-hoMG4CDjo6qw0Z4Uk3peUhCOR=O+caA@mail.gmail.com>
Bob Jolliffe <bobjolliffe@gmail.com> writes:
> I have an interesting problem. I have a string field in a table which
> (sometimes) is expected to contain numeric values ie. a cast of the
> field to INTEGER is supposed to succeed.
> My issue is that the application is running in Bangladesh, and
> sometimes the users have entered values using Bangla characters. eg.
> "৮" rather than "8". (Note that this shouldnt have been possible to
> enter in the first place, but we can ignore that for now. They are
> there, I have to somehow deal with it.)
> Is there a way with LOCALE settings to get this cast to work
> correctly?
Doubt it :-(. ISTM it's certainly outside the charter of int4in to
do that. Ideally to_number() would handle it, but I don't think it
does at the moment. Probably your best bet is to translate those
characters to regular ASCII digits using replace(), then cast.
It'd be a bit tedious, but fortunately there are only 10 cases
to consider, and you could wrap that up in a function.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, bobjolliffe@gmail.com
Subject: Re: casting Bangla characters to NUMERIC
In-Reply-To: <3579.1574699260@sss.pgh.pa.us>
References: <CACd=f9e+D_m=hTm9fV-hoMG4CDjo6qw0Z4Uk3peUhCOR=O+caA@mail.gmail.com> <3579.1574699260@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox