#include <glibmm.h>
#include <iostream>

class MyParser : public Glib::Markup::Parser
{
    public:
        MyParser () {}
        virtual void on_start_element (Glib::Markup::ParseContext& context, const Glib::ustring& element_name, const Parser::AttributeMap& attributes) { }
        virtual void on_end_element (Glib::Markup::ParseContext& context, const Glib::ustring& element_name) { }
        virtual void on_text (Glib::Markup::ParseContext& context, const Glib::ustring& text) { }
        virtual void on_passthrough (Glib::Markup::ParseContext& context, const Glib::ustring& passthrough_text) { }
        virtual void on_error (Glib::Markup::ParseContext& context, const Glib::MarkupError& error) { }
};

int main (int argc, char** argv)
{
    char invalid_utf8[] = {0x1, 0x2, 0x3, 0x4, 0x5, 0xff};
    MyParser parser;
    Glib::Markup::ParseContext context (parser);
    try
    {
        // almost guaranteed to be invalid utf-8
        context.parse (invalid_utf8);
    }
    catch (const Glib::MarkupError& exception)
    {
        std::cerr << "Glib::MarkupError: " << exception.what () << std::endl;
    }
    catch (const Glib::ConvertError& exception)
    {
        std::cerr << "Glib::ConvertError: " << exception.what () << std::endl;
    }
    catch (const Glib::Error& exception)
    {
        std::cerr << "Glib::Error: " << exception.what () << std::endl;
    }
    return 0;
}
