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_slang.c

    r859 r929  
    393393{
    394394#ifdef HAVE_SLSMG_UTF8_ENABLE
    395     static const uint8_t mark[7] =
    396     {
    397         0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC
    398     };
    399 
    400     char buf[10], *parser;
     395    char buf[10];
    401396    int bytes;
    402 #endif
    403 
    404     if(ch < 0x80)
    405     {
    406         SLsmg_write_char(ch);
    407         return;
    408     }
    409 
    410 #ifdef HAVE_SLSMG_UTF8_ENABLE
    411     bytes = (ch < 0x800) ? 2 : (ch < 0x10000) ? 3 : 4;
     397
     398    bytes = _cucul_utf32_to_utf8(buf, ch);
    412399    buf[bytes] = '\0';
    413     parser = buf + bytes;
    414 
    415     switch(bytes)
    416     {
    417         case 4: *--parser = (ch | 0x80) & 0xbf; ch >>= 6;
    418         case 3: *--parser = (ch | 0x80) & 0xbf; ch >>= 6;
    419         case 2: *--parser = (ch | 0x80) & 0xbf; ch >>= 6;
    420     }
    421     *--parser = ch | mark[bytes];
    422 
    423400    SLsmg_write_string(buf);
    424401#else
    425     SLsmg_write_char(' ');
     402    SLsmg_write_char(ch < 0x80 ? ch : ' ');
    426403#endif
    427404}
Note: See TracChangeset for help on using the changeset viewer.