[libgda] Gda-Sql: specify charset in HTML output



commit 8ae7bcc6c4e4841f21eaae26e2d9e4dfd203c0d3
Author: Vivien Malerba <malerba gnome-db org>
Date:   Thu May 12 18:50:35 2011 +0200

    Gda-Sql: specify charset in HTML output

 tools/gda-sql.c |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)
---
diff --git a/tools/gda-sql.c b/tools/gda-sql.c
index 63b8d4a..f7d094c 100644
--- a/tools/gda-sql.c
+++ b/tools/gda-sql.c
@@ -1803,13 +1803,19 @@ data_model_to_string (SqlConsole *console, GdaDataModel *model)
 		break;
 	case OUTPUT_FORMAT_HTML: {
 		xmlBufferPtr buffer;
-		xmlNodePtr html, table, node, row_node, col_node;
+		xmlNodePtr top, div, table, node, row_node, col_node, header, meta;
 		gint ncols, nrows, i, j;
 		gchar *str;
 
-		html = xmlNewNode (NULL, BAD_CAST "div");
+		top = xmlNewNode (NULL, BAD_CAST "html");
+		header = xmlNewChild (top, NULL, BAD_CAST "head", NULL);
+		meta = xmlNewChild (header, NULL, BAD_CAST "meta", NULL);
+		xmlSetProp (meta, BAD_CAST "http-equiv", BAD_CAST "content-type");
+		xmlSetProp (meta, BAD_CAST "content", BAD_CAST "text/html; charset=UTF-8");
 
-		table = xmlNewChild (html, NULL, BAD_CAST "table", NULL);
+		div = xmlNewChild (top, NULL, BAD_CAST "body", NULL);
+
+		table = xmlNewChild (div, NULL, BAD_CAST "table", NULL);
 		xmlSetProp (table, BAD_CAST "border", BAD_CAST "1");
 		
 		if (g_object_get_data (G_OBJECT (model), "name"))
@@ -1845,16 +1851,16 @@ data_model_to_string (SqlConsole *console, GdaDataModel *model)
 			}
 		}
 
-		node = xmlNewChild (html, NULL, BAD_CAST "p", NULL);
+		node = xmlNewChild (div, NULL, BAD_CAST "p", NULL);
 		str = g_strdup_printf (ngettext ("(%d row)", "(%d rows)", nrows), nrows);
 		xmlNodeSetContent (node, BAD_CAST str);
 		g_free (str);
 
 		buffer = xmlBufferCreate ();
-		xmlNodeDump (buffer, NULL, html, 0, 1);
+		xmlNodeDump (buffer, NULL, top, 0, 1);
 		str = g_strdup ((gchar *) xmlBufferContent (buffer));
 		xmlBufferFree (buffer);
-		xmlFreeNode (html);
+		xmlFreeNode (top);
 		return str;
 	}
 	default: 



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