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 - [EMAIL PROTECTED]

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Reply via email to