[libgda] Improved gda_data_model_dump()'s output



commit de850572ad56ad68945b5a65d5057cd00d42a518
Author: Vivien Malerba <malerba gnome-db org>
Date:   Thu Jul 15 19:19:33 2010 +0200

    Improved gda_data_model_dump()'s output

 libgda/gda-data-model.c |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/libgda/gda-data-model.c b/libgda/gda-data-model.c
index 09fef26..373132b 100644
--- a/libgda/gda-data-model.c
+++ b/libgda/gda-data-model.c
@@ -38,6 +38,7 @@
 #include <libgda/gda-enums.h>
 #include <string.h>
 #ifdef HAVE_LOCALE_H
+#include <langinfo.h>
 #include <locale.h>
 #endif
 #include "csv.h"
@@ -2075,13 +2076,26 @@ real_gda_data_model_dump_as_string (GdaDataModel *model, gboolean dump_attribute
 	gchar *sep_col_e  = "   ";
 #endif
 	gchar *sep_row  = "-+-";
-	gchar sep_fill = '-';
+	gchar *sep_fill = "-";
 	gint i, j;
 	const GValue *value;
 
 	gint col_offset = dump_rows ? 1 : 0;
 	GdaDataModel *ramodel = NULL;
 
+#ifdef HAVE_LOCALE_H
+	char *current_locale;
+	int utf8_mode;
+	current_locale = setlocale (LC_ALL, "");
+	utf8_mode = (strcmp (nl_langinfo(CODESET), "UTF-8") == 0);
+	if (utf8_mode) {
+		sep_col = " â?? ";
+		sep_fill = "â??";
+		sep_row = "â??â?¼â??";
+	}
+	setlocale (LC_ALL, current_locale);
+#endif
+
 	string = g_string_new ("");
 
 	/* compute the columns widths: using column titles... */
@@ -2218,7 +2232,7 @@ real_gda_data_model_dump_as_string (GdaDataModel *model, gboolean dump_attribute
 		if (i != 0)
 			g_string_append_printf (string, "%s", sep_row);
 		for (j = 0; j < cols_size [i]; j++)
-			g_string_append_c (string, sep_fill);
+			g_string_append (string, sep_fill);
 	}
 	g_string_append_c (string, '\n');
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]