[PATCH 3/6] psql: Create table format

From: Roger Leigh <rleigh(at)debian(dot)org>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Roger Leigh <rleigh(at)debian(dot)org>
Subject: [PATCH 3/6] psql: Create table format
Date: 2009-08-22 15:59:47
Message-ID: 1250956790-18404-4-git-send-email-rleigh@debian.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)debian(dot)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,
void
printTable(const printTableContent *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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Roger Leigh 2009-08-22 15:59:48 [PATCH 4/6] psql: Pass table formatting object to text output functions
Previous Message Roger Leigh 2009-08-22 15:59:46 [PATCH 2/6] psql: Add table formats for ASCII and UTF-8