added UTF-8 string checking, raise a problem, need debug Daniel

* debugXML.c include/libxml/xmlerror.h: added UTF-8 string checking,
  raise a problem, need debug
Daniel
diff --git a/debugXML.c b/debugXML.c
index 3728470..9b7163d 100644
--- a/debugXML.c
+++ b/debugXML.c
@@ -164,7 +164,7 @@
 		    msg, extra);
 }
 static void
-xmlDebugErr3(xmlDebugCtxtPtr ctxt, int error, const char *msg, char *extra)
+xmlDebugErr3(xmlDebugCtxtPtr ctxt, int error, const char *msg, const char *extra)
 {
     ctxt->errors++;
     __xmlRaiseError(NULL, NULL, NULL,
@@ -208,6 +208,25 @@
     }
 }
 
+/**
+ * xmlCtxtCheckString:
+ * @ctxt: the debug context
+ * @str: the string
+ *
+ * Do debugging on the string, currently it just checks the UTF-8 content
+ */
+static void
+xmlCtxtCheckString(xmlDebugCtxtPtr ctxt, const xmlChar * str)
+{
+    if (str == NULL) return;
+    if (ctxt->check) {
+        if (!xmlCheckUTF8(str)) {
+	    xmlDebugErr3(ctxt, XML_CHECK_NOT_DTD,
+			 "String is not UTF-8 %s", (const char *) str);
+	}
+    }
+}
+
 static void
 xmlCtxtGenericNodeCheck(xmlDebugCtxtPtr ctxt, xmlNodePtr node) {
     if (node->parent == NULL)
@@ -263,6 +282,12 @@
 	    xmlCtxtNsCheckScope(ctxt, node, node->ns);
     }
 
+    if ((node->type != XML_ELEMENT_NODE) &&
+        (node->type != XML_HTML_DOCUMENT_NODE) &&
+        (node->type != XML_DOCUMENT_NODE)) {
+	if (node->content != NULL)
+	    xmlCtxtCheckString(ctxt, (const char *) node->content);
+    }
 }
 
 static void
@@ -270,8 +295,9 @@
 {
     int i;
 
-    if (ctxt->check)
+    if (ctxt->check) {
         return;
+    }
     /* TODO: check UTF8 content of the string */
     if (str == NULL) {
         fprintf(ctxt->output, "(NULL)");