Re: Unicode UTF-8 table formatting for psql text output
Roger Leigh <rleigh@codelibre.net>
From: Roger Leigh <rleigh@codelibre.net>
To: Alvaro Herrera <alvherre@commandprompt.com>
Cc: Robert Haas <robertmhaas@gmail.com>, Roger Leigh <rleigh@debian.org>, pgsql-hackers@postgresql.org
Date: 2009-08-25T12:10:22Z
Lists: pgsql-hackers
Attachments
- psql-utf8-table-2.patch (text/x-diff) patch
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.