/* XXX - should map lead and trail surrogate values to a "substitute" UTF-8 character? XXX - should map code points > 10FFFF to REPLACEMENT CHARACTERs. XXX - if the number of bytes isn't a multiple of 4, should put a REPLACEMENT CHARACTER at the end.  */
guint8* get_ucs_4_string(wmem_allocator_t *scope, const guint8 *ptr, gint length, const guint encoding)
/* XXX - should map lead and trail surrogate values to a "substitute" UTF-8 character? XXX - should map code points > 10FFFF to REPLACEMENT CHARACTERs. XXX - if the number of bytes isn't a multiple of 4, should put a REPLACEMENT CHARACTER at the end.  */
guint8* get_ucs_4_string(wmem_allocator_t *scope, const guint8 *ptr, gint length, const guint encoding)
{
    gunichar       uchar;
    gint           i;
    wmem_strbuf_t *strbuf;
    strbuf = wmem_strbuf_sized_new(scope, length+1, 0);
    for(i = 0; i + 3 < length; i += 4) {
        if (encoding == ENC_BIG_ENDIAN)
            uchar = pntoh32(ptr + i);
        else
            uchar = pletoh32(ptr + i);
        wmem_strbuf_append_unichar(strbuf, uchar);
    }
    return (gchar *)wmem_strbuf_finalize(strbuf);
}