diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index 85e9375..95f1365 100644
--- a/doc/src/sgml/ref/psql-ref.sgml
+++ b/doc/src/sgml/ref/psql-ref.sgml
@@ -192,6 +192,19 @@ PostgreSQL documentation
     </varlistentry>
 
     <varlistentry>
+      <term><option>-G</option></term>
+      <term><option>--no-pretty-formatting</option></term>
+      <para>
+      Only use ASCII characters to draw tables. Without this option,
+      box drawing characters may be used if avilable which will result
+      in nicer output.  However, if compatibility with the output of
+      older psql versions, or psql used in other locales is required, it
+      may be desirable to disable pretty table formatting in these
+      situations.
+      </para>
+    </varlistentry>
+
+    <varlistentry>
       <term><option>-h <replaceable class="parameter">hostname</replaceable></></term>
       <term><option>--host <replaceable class="parameter">hostname</replaceable></></term>
       <listitem>
diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c
index d498d58..d596ece 100644
--- a/src/bin/psql/help.c
+++ b/src/bin/psql/help.c
@@ -121,6 +121,8 @@ usage(void)
 	   "                           set field separator (default: \"%s\")\n"),
 		   DEFAULT_FIELD_SEP);
 	printf(_("  -H, --html               HTML table output mode\n"));
+	printf(_("  -G, --no-pretty-formatting\n"
+	"                           only use ASCII characters to format tables\n"));
 	printf(_("  -P, --pset=VAR[=ARG]     set printing option VAR to ARG (see \\pset command)\n"));
 	printf(_("  -R, --record-separator=STRING\n"
 	"                           set record separator (default: newline)\n"));
diff --git a/src/bin/psql/print.c b/src/bin/psql/print.c
index 41d508e..e01e512 100644
--- a/src/bin/psql/print.c
+++ b/src/bin/psql/print.c
@@ -2290,9 +2290,10 @@ printTable(const printTableContent *cont, FILE *fout, FILE *flog)
 	const printTextFormat	*text_format = &asciiformat;
 
 #if (defined(HAVE_LANGINFO_H) && defined(CODESET))
-	if (pg_strcasecmp(nl_langinfo(CODESET), "UTF-8") == 0 ||
-	    pg_strcasecmp(nl_langinfo(CODESET), "utf8") == 0 ||
-	    pg_strcasecmp(nl_langinfo(CODESET), "CP65001") == 0)
+	if ((pg_strcasecmp(nl_langinfo(CODESET), "UTF-8") == 0 ||
+	     pg_strcasecmp(nl_langinfo(CODESET), "utf8") == 0 ||
+	     pg_strcasecmp(nl_langinfo(CODESET), "CP65001") == 0) &&
+	    cont->opt->use_text_format)
 		text_format = &utf8format;
 #endif
 
diff --git a/src/bin/psql/print.h b/src/bin/psql/print.h
index ea1dc97..97772a6 100644
--- a/src/bin/psql/print.h
+++ b/src/bin/psql/print.h
@@ -27,6 +27,7 @@ enum printFormat
 typedef struct printTableOpt
 {
 	enum printFormat format;	/* one of the above */
+	bool		use_text_format; /* use text formats for pretty printing */
 	bool		expanded;		/* expanded/vertical output (if supported by
 								 * output format) */
 	unsigned short int border;	/* Print a border around the table. 0=none,
diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c
index 429e5d9..3fdf904 100644
--- a/src/bin/psql/startup.c
+++ b/src/bin/psql/startup.c
@@ -125,6 +125,7 @@ main(int argc, char *argv[])
 
 	/* We rely on unmentioned fields of pset.popt to start out 0/false/NULL */
 	pset.popt.topt.format = PRINT_ALIGNED;
+	pset.popt.topt.use_text_format = 1;
 	pset.popt.topt.border = 1;
 	pset.popt.topt.pager = 1;
 	pset.popt.topt.start_table = true;
@@ -317,6 +318,7 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
 		{"list", no_argument, NULL, 'l'},
 		{"log-file", required_argument, NULL, 'L'},
 		{"no-readline", no_argument, NULL, 'n'},
+		{"no-pretty-formatting", no_argument, NULL, 'G'},
 		{"single-transaction", no_argument, NULL, '1'},
 		{"output", required_argument, NULL, 'o'},
 		{"port", required_argument, NULL, 'p'},
@@ -346,7 +348,7 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
 
 	memset(options, 0, sizeof *options);
 
-	while ((c = getopt_long(argc, argv, "aAc:d:eEf:F:h:HlL:no:p:P:qR:sStT:U:v:VwWxX?1",
+	while ((c = getopt_long(argc, argv, "aAc:d:eEf:GF:h:HlL:no:p:P:qR:sStT:U:v:VwWxX?1",
 							long_options, &optindex)) != -1)
 	{
 		switch (c)
@@ -383,6 +385,9 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
 			case 'F':
 				pset.popt.topt.fieldSep = pg_strdup(optarg);
 				break;
+			case 'G':
+				pset.popt.topt.use_text_format = false;
+				break;
 			case 'h':
 				options->host = optarg;
 				break;
diff --git a/src/test/regress/pg_regress_main.c b/src/test/regress/pg_regress_main.c
index cb477a6..2c2762b 100644
--- a/src/test/regress/pg_regress_main.c
+++ b/src/test/regress/pg_regress_main.c
@@ -59,7 +59,7 @@ psql_start_test(const char *testname,
 	add_stringlist_item(expectfiles, expectfile);
 
 	snprintf(psql_cmd, sizeof(psql_cmd),
-			 SYSTEMQUOTE "\"%s%spsql\" -X -a -q -d \"%s\" < \"%s\" > \"%s\" 2>&1" SYSTEMQUOTE,
+			 SYSTEMQUOTE "\"%s%spsql\" -X -a -q -G -d \"%s\" < \"%s\" > \"%s\" 2>&1" SYSTEMQUOTE,
 			 psqldir ? psqldir : "",
 			 psqldir ? "/" : "",
 			 dblist->str,
