Re: Inverse convertion for pg_mb2wchar - Mailing list pgsql-hackers

From Alexander Korotkov
Subject Re: Inverse convertion for pg_mb2wchar
Date
Msg-id CAPpHfdu3P-PocJ8QXmLzcn0H2n9_xLUikv3JVB_PLb6DF==nQg@mail.gmail.com
Whole thread Raw
In response to Re: Inverse convertion for pg_mb2wchar  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
On Thu, Dec 1, 2011 at 12:30 AM, Robert Haas <robertmhaas@gmail.com> wrote:
On Mon, Nov 21, 2011 at 11:49 AM, Alexander Korotkov
<aekorotkov@gmail.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.

pgsql-hackers by date:

Previous
From: Kohei KaiGai
Date:
Subject: Re: Refactoring on DROP/ALTER SET SCHEMA/ALTER RENAME TO statement
Next
From: Alexander Korotkov
Date:
Subject: Re: WIP: index support for regexp search