Ignore:
Timestamp:
May 5, 2006, 4:03:40 PM (14 years ago)
Author:
Sam Hocevar
Message:
  • Factored more UTF32 to UTF8 conversions using _cucul_utf32_to_utf8().
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/caca/driver_ncurses.c

    r859 r929  
    488488{
    489489#if defined(HAVE_NCURSESW_NCURSES_H)
    490     static const uint8_t mark[7] =
    491     {
    492         0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC
    493     };
    494 
    495     char buf[10], *parser;
     490    char buf[10];
    496491    int bytes;
    497 #endif
    498 
    499     if(ch < 0x80)
    500     {
    501         addch(ch);
    502         return;
    503     }
    504 
    505 #if defined(HAVE_NCURSESW_NCURSES_H)
    506     if(ch < 0x10000)
    507     {
    508         addch(ch); /* FIXME: doesn't work either */
    509         return;
    510     }
    511 
    512     bytes = (ch < 0x800) ? 2 : (ch < 0x10000) ? 3 : 4;
     492
     493    bytes = _cucul_utf32_to_utf8(buf, ch);
    513494    buf[bytes] = '\0';
    514     parser = buf + bytes;
    515 
    516     switch(bytes)
    517     {
    518         case 4: *--parser = (ch | 0x80) & 0xbf; ch >>= 6;
    519         case 3: *--parser = (ch | 0x80) & 0xbf; ch >>= 6;
    520         case 2: *--parser = (ch | 0x80) & 0xbf; ch >>= 6;
    521     }
    522     *--parser = ch | mark[bytes];
    523 
    524495    addstr(buf);
    525496#else
    526     addch(' ');
     497    addch(ch < 0x80 ? ch : '?');
    527498#endif
    528499}
Note: See TracChangeset for help on using the changeset viewer.