Re: client side syntax error localisation for psql (v1)

From: Tatsuo Ishii <t-ishii(at)sra(dot)co(dot)jp>
To: coelho(at)cri(dot)ensmp(dot)fr
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: client side syntax error localisation for psql (v1)
Date: 2004-03-12 12:35:58
Message-ID: 20040312.213558.104029825.t-ishii@sra.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> PQmblen returns the storage size, which is not necessarily same as the
> character width reprensented in a terminal. For example for a kanji
> character in UTF-8 PQmblen returns 3, but it ocuppies 2 x ASCII
> character space, not x 3. Isn't that a problem for you?
>
> > > 2) It assume all encodings are "ASCII compatible". Apparently some
> > > client-side-only encodings do not satisfy this request. Examples
> > > include SJIS, Big5.
> >
> > What I mean by "ASCII compatible" is that spaces, new lines, carriage
> > returns, tabs and NULL (C string terminaison) are one byte characters.
> > This assumption seemed pretty safe to me.
> >
> > If this is not the case, I cannot understand how any error message could
> > work in psql. If one printf(" "), that would not be a space character?
> > Or is the terminal doing some "on the fly" translation?? What if a
> > file is read with such encoding??? Or is there a special compilation
> > option to generate special strings, but in this case the executable
> > would not be compatible with any other terminal????
> >
> > Well, I just underline my lack of knowledge here:-(
> >
> > If not, how can I detect these special characters that I need to change ?
> > Maybe I could translate the string to a pg_wchar[] if the function is
> > available to psql?
>
> I think you can do it safely using PQmblen.
>
> 1) start from the begining of the target string
>
> 2) apply PQmblen
>
> 3) if it returns 1, you can do the spcecial character detection
>
> 4) otherwise it must not be an ASCII character and you can skip as
> many characters as PQmnlen returns
>
> 5) goto 1) if any characters remain
~~of course this should be 2)
--
Tatsuo Ishii

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Fabien COELHO 2004-03-12 12:57:08 Re: client side syntax error localisation for psql (v1)
Previous Message Magnus Hagander 2004-03-12 11:39:03 Re: [HACKERS] The Name Game: postgresql.net vs. pgfoundry.org