#include <glib.h>
#include <glib/gmarkup.h>
#include <string.h>

const GMarkupParser parser = {
  NULL,
  NULL,
  NULL,
  NULL,
  NULL
};

int main (int argc, char** argv)
{
    const char invalid_utf8[] = {0x1, 0x2, 0x3, 0x4, 0x5, 0xff, 0};

    GMarkupParseContext* context = g_markup_parse_context_new (&parser, (GMarkupParseFlags)0, NULL, NULL);

    GError* error = NULL;
    g_markup_parse_context_parse(context, invalid_utf8, strlen(invalid_utf8), &error);
  
    if(error)
    {
       const gchar* message = error->message;
       if(message)
       {
         /* Check that it is UTF-8: */
         const gchar *end = NULL;
         if(!g_utf8_validate(message, -1, &end))
         {
           g_warning("GError::message contained invalid UTF8");
         }
       }
    }
   
    g_markup_parse_context_free(context);

    return 0;
}
