Ejemplo n.º 1
0
hwfont Tutf_UTF_32_to_CP437(hwfont c)
{
#define EL(x) +1
    enum {
        n = T_NLIST(CP437,EL) + 1,    /* +1 to manually map T_UTF_32_CHECK_MARK -> T_CP437_SQUARE_ROOT below */
        n_power_of_2 = NEXT_POWER_OF_2(n)
    };
#undef EL
    
    static utf32_hash_table * table = NULL;
    
    /* Codepage 437 (VGA) obviously cannot contain all unicode chars. this is just a best effort. */
    if (!table) {
	table = utf32_hash_create(Tutf_CP437_to_UTF_32, n, n_power_of_2);

        /* manually map T_UTF_32_CHECK_MARK -> T_CP437_SQUARE_ROOT */
        utf32_hash_insert_at(table, n - 1, T_UTF_32_CHECK_MARK, T_CP437_SQUARE_ROOT);
    }
    return utf32_hash_search(table, c, ttrue);
}
Ejemplo n.º 2
0
hwfont T_CAT(Tutf_UTF_16_to_,T_TEMPLATE) (hwfont c)
{
#define EL(x) +1
    enum {
        n = T_NLIST(T_TEMPLATE,EL) + 0, /* +0 in case T_NLIST() expands to nothing */
        n_power_of_2 = NEXT_POWER_OF_2(n)
    };
#undef EL
    
    static utf16_hash_table * table = NULL;
    
    /* a single 8-bit charset obviously cannot contain all unicode chars. this is just a best effort. */
    if (!table)
	table = utf16_hash_create(T_CAT3(Tutf_,T_TEMPLATE,_to_UTF_16), n, n_power_of_2);

#ifdef TEMPLATE_REDEFINES_ASCII
    return utf16_hash_search(table, c, FALSE);
#else
    return utf16_hash_search(table, c, TRUE);
#endif
}