/* Given a wmem scope, a pointer, and a length, and a translation table, treat the string of bytes referred to by the pointer and length as a string encoded in EBCDIC using one octet per character, and return a pointer to a UTF-8 string, allocated using the wmem scope.  */
guint8* get_ebcdic_string(wmem_allocator_t *scope, const guint8 *ptr, gint length)
/* Given a wmem scope, a pointer, and a length, and a translation table, treat the string of bytes referred to by the pointer and length as a string encoded in EBCDIC using one octet per character, and return a pointer to a UTF-8 string, allocated using the wmem scope.  */
guint8* get_ebcdic_string(wmem_allocator_t *scope, const guint8 *ptr, gint length)
{
    wmem_strbuf_t *str;
    str = wmem_strbuf_sized_new(scope, length+1, 0);
    while (length > 0) {
        guint8 ch = *ptr;
        wmem_strbuf_append_unichar(str, EBCDIC_translate_ASCII[ch]);
        ptr++;
        length--;
    }
    return (guint8 *) wmem_strbuf_finalize(str);
}