[PATCH 3/6] psql: Create table format - Mailing list pgsql-hackers

From Roger Leigh
Subject [PATCH 3/6] psql: Create table format
Date
Msg-id 1250956790-18404-4-git-send-email-rleigh@debian.org
Whole thread Raw
In response to [PATCH 1/6] psql: Abstract table formatting characters used for different line types.  (Roger Leigh <rleigh@debian.org>)
List pgsql-hackers
Default to using the ASCII table.  However, if a UTF-8
locale codeset is in use, switch to the UTF-8 table.

Signed-off-by: Roger Leigh <rleigh@debian.org>
---src/bin/psql/print.c |   11 ++++++++++-1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/src/bin/psql/print.c b/src/bin/psql/print.c
index 9dec77d..6f5dcd4 100644
--- a/src/bin/psql/print.c
+++ b/src/bin/psql/print.c
@@ -21,6 +21,9 @@#endif#include <locale.h>
+#ifdef HAVE_LANGINFO_H
+#include <langinfo.h>
+#endif#include "catalog/pg_type.h"#include "pqsignal.h"
@@ -2232,7 +2235,13 @@ IsPagerNeeded(const printTableContent *cont, const int extra_lines, FILE
**fout,voidprintTable(constprintTableContent *cont, FILE *fout, FILE *flog){
 
-    bool        is_pager = false;
+    bool            is_pager = false;
+    const printTextFormat    *text_format = &asciiformat;
+
+#if (defined(HAVE_LANGINFO_H) && defined(CODESET))
+    if (!strcmp(nl_langinfo(CODESET), "UTF-8"))
+        text_format = &utf8format;
+#endif    if (cancel_pressed)        return;
-- 
1.6.3.3



pgsql-hackers by date:

Previous
From: Roger Leigh
Date:
Subject: Unicode UTF-8 table formatting for psql text output
Next
From: Roger Leigh
Date:
Subject: Submitted patches stuck in moderation queue