Re: Inverse convertion for pg_mb2wchar

From: Alexander Korotkov <aekorotkov(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Inverse convertion for pg_mb2wchar
Date: 2011-12-01 13:32:11
Message-ID: CAPpHfdu3P-PocJ8QXmLzcn0H2n9_xLUikv3JVB_PLb6DF==nQg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Dec 1, 2011 at 12:30 AM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:

> On Mon, Nov 21, 2011 at 11:49 AM, Alexander Korotkov
> <aekorotkov(at)gmail(dot)com> wrote:
> > I've a question about pg_mb2wchar function. Is there any way for inverse
> > convertion pg_wchar* to char*?
> > I've looked to pg_wchar_tbl table definition, and I didn't find anything
> > about inverse transformation. So, any change to get inverse convertion?
> > I'm experimenting with index support for regexp search and I'm trying to
> get
> > some characters back from color map.
>
> Well, any char can presumably also be represented as a wchar, but the
> reverse isn't necessarily true...
>

So, if wchar can't be presented as sequence of chars, it means that it
can't occurs in string in server encoding. In this situation it's enough
for me to know that it is so for paticular wchar.
I found that for UTF8 uncoding wchar is unicode. For single-bytes encodings
wchar just hold original value in it's lower byte. And there are some
conversions for PG_EUC_JP, PG_EUC_CN, PG_EUC_KR, PG_EUC_TW, PG_EUC_JIS_2004
which are not clear for me, but it's seems to be feasible to write inverse
conversion code using existing code of direct conversion.

> (What's a color map?)

Regexp engine translates regexp to finite state automatum. In order to
automatum don't have too much arc, characters are grouped to colors.
Colormap maps wchar -> color number. Since analyze automatum produced by
regexp engine, I need to convert wchar to original character.

------
With best regards,
Alexander Korotkov.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Korotkov 2011-12-01 13:34:58 Re: WIP: index support for regexp search
Previous Message Kohei KaiGai 2011-12-01 13:25:21 Re: Refactoring on DROP/ALTER SET SCHEMA/ALTER RENAME TO statement