question about char/wchar/mb utils

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: PostgreSQL Developers <pgsql-hackers(at)postgresql(dot)org>
Subject: question about char/wchar/mb utils
Date: 2004-03-10 12:13:55
Message-ID: Pine.LNX.4.58.0403101248060.32532@sablons.cri.ensmp.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Hello hackers,

I'm working on a very small patch to add syntax error localisation on the
client side in psql, as it seems to be the place. Something like:

ERROR: syntax error at character 12345
QUERY: ... WHERE foo IS NUL AND ...
QUERY: ^

My current issue is how to build the query excerpt to be displayed.
I'm in the "psql/common.c" file.

The query is a char*, and I guess it is in the client encoding, so that
one character is not one byte.

My first idea was to transform the char into a wchar and then work
directly and simply on the wchar string (to fix tabs and so) ...

However, although I have found a function to build the wchar string
(pg_mb2wchar), I haven't found the reverse (yet) :-(, that is to convert
my wchar extract to a char string compatible with the client encoding.

Is there such a function somewhere? It seems that wchar is a one-way
type, once you're there you're stuck with it:-(

If not, what are the other options?

The issue is to be able to work on a constant width string without having
to care about different mb encodings, otherwise the code is going to be a
little bit tricky... I guess I can do it, but the reverse conversion
function looked more appealing to me;-)

Or am still I off my shoes? (translator: a cote de mes pompes;-);

Thanks, for any advice on this point or others,

have a nice day,

--
Fabien Coelho - coelho(at)cri(dot)ensmp(dot)fr

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Matthew Kirkwood 2004-03-10 13:10:12 Re: Scalable postgresql using sys_epoll
Previous Message Christopher Kings-Lynne 2004-03-10 12:06:36 Re: [PATCHES] log_line_info