#include <glib.h>
#include <stdio.h>

#define UNICHAR "ö"
#define BUF_LEN 2

int
main (int    argc,
      char **argv)
{
        gunichar buf[BUF_LEN];
        gsize real_len, utf8_len;
        gboolean res;
        char utf8[7];

        printf ("Original unichar='%s'\n", UNICHAR);

        res = g_unicode_canonical_decomposition_to_buffer
                (g_utf8_get_char (UNICHAR), buf, BUF_LEN, &real_len);
        g_assert (res == TRUE);

        printf ("BUF_LEN=%d; real_len=%d\n", BUF_LEN, real_len);

        utf8_len = g_unichar_to_utf8 (buf[0], utf8);
        *(utf8 + utf8_len) = 0;
        printf ("First unichar='%s'\n", utf8);
        
        utf8_len = g_unichar_to_utf8 (buf[1], utf8);
        *(utf8 + utf8_len) = 0;
        printf ("Second unichar='%s'\n", utf8);
}
