Changeset 579 for libcaca/trunk
- Timestamp:
- Mar 10, 2006, 10:34:16 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/caca/driver_slang.c
r557 r579 105 105 */ 106 106 static void slang_init_palette(void); 107 static void slang_write_utf32(uint32_t); 107 108 108 109 #if defined(HAVE_SIGNAL) … … 161 162 SLtt_Has_Alt_Charset = 0; 162 163 163 cucul_set_size(kk->qq, SLtt_Screen_Cols, SLtt_Screen_Rows); 164 SLsmg_utf8_enable(1); /* 1 == force, 0 == disable, -1 == autodetect */ 165 SLtt_utf8_enable(1); 166 167 _cucul_set_size(kk->qq, SLtt_Screen_Cols, SLtt_Screen_Rows); 164 168 165 169 return 0; … … 215 219 { 216 220 SLsmg_set_color(slang_assoc[*attr++]); 217 if(c > 0x00000020 && 0x00000080) 218 SLsmg_write_char((char)c); 219 else 220 SLsmg_write_char(' '); 221 slang_write_utf32(c); 221 222 } 222 223 else … … 235 236 #else 236 237 SLsmg_set_color(*attr++); 237 if(c > 0x00000020 && 0x00000080) 238 SLsmg_write_char((char)c); 239 else 240 SLsmg_write_char(' '); 238 slang_write_utf32(c); 241 239 #endif 242 240 } … … 377 375 } 378 376 377 static void slang_write_utf32(uint32_t c) 378 { 379 static const uint8_t mark[7] = 380 { 381 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC 382 }; 383 384 char buf[10], *parser; 385 int bytes; 386 387 if(c < 0x80) 388 { 389 SLsmg_write_char(c); 390 return; 391 } 392 393 bytes = (c < 0x800) ? 2 : (c < 0x10000) ? 3 : 4; 394 buf[bytes] = '\0'; 395 parser = buf + bytes; 396 397 switch(bytes) 398 { 399 case 4: *--parser = (c | 0x80) & 0xbf; c >>= 6; 400 case 3: *--parser = (c | 0x80) & 0xbf; c >>= 6; 401 case 2: *--parser = (c | 0x80) & 0xbf; c >>= 6; 402 } 403 *--parser = c | mark[bytes]; 404 405 SLsmg_write_string(buf); 406 } 407 379 408 #if defined(HAVE_SIGNAL) 380 409 static RETSIGTYPE sigwinch_handler(int sig)
Note: See TracChangeset
for help on using the changeset viewer.