Re: Unicode UTF-8 table formatting for psql text output - Mailing list pgsql-hackers

From Roger Leigh
Subject Re: Unicode UTF-8 table formatting for psql text output
Date
Msg-id 20090825121021.GA7283@codelibre.net
Whole thread Raw
In response to Re: Unicode UTF-8 table formatting for psql text output  (Alvaro Herrera <alvherre@commandprompt.com>)
Responses Re: Unicode UTF-8 table formatting for psql text output  (Alvaro Herrera <alvherre@commandprompt.com>)
List pgsql-hackers
On Sun, Aug 23, 2009 at 06:33:49PM -0400, Alvaro Herrera wrote:
> Roger Leigh escribió:
>
> > +#if (defined(HAVE_LANGINFO_H) && defined(CODESET))
> > +    if (!strcmp(nl_langinfo(CODESET), "UTF-8"))
> > +        text_format = &utf8format;
> > +#endif
>
> I think you should also try to match to "UTF8", and do it in
> case-insensitive manner (pg_strcasecmp), just like chklocale.c.

An updated copy of the patch is attached.  This has the following
changes:

- matches UTF-8, utf8 and CP65001 case insensitively as for chklocale.c
- uses fprintf in place of repeated fputs/fputc calls
- moved hrule from table to line formatting
- moved vrule from table to separate line format

The latter two allow complete specification of all the characters used
to draw.  You can now have different horizonal rule types for the
different line types (demonstrated by making PRINT_RULE_MIDDLE thick
rather than thin).  The same applies to the vertical rules, but since
these are drawn intermixed with data these are a separate line format
in their own right (PRINT_RULE_DATA).

You can if you like make incredibly ugly tables consisting of all sorts
of thin, thick and double ruled lines running horizontally and
vertically at all edges and positions.  The patch as it is keeps this
subtle!  But, a potential future extension to this could be a \pset
command to customise the table style in addition to border printing,
since the code is now there to do this.


Regards,
Roger

--
  .''`.  Roger Leigh
 : :' :  Debian GNU/Linux             http://people.debian.org/~rleigh/
 `. `'   Printing on GNU/Linux?       http://gutenprint.sourceforge.net/
   `-    GPG Public Key: 0x25BFB848   Please GPG sign your mail.

Attachment

pgsql-hackers by date:

Previous
From: Paul Matthews
Date:
Subject: Re: Slaying the HYPOTamus
Next
From: Magnus Hagander
Date:
Subject: Re: pg_hba.conf: samehost and samenet