--- src/help.c +++ src/help.c @@ -445,7 +445,11 @@ #ifndef HAVE_SLANG addch (acs_map [c]); #else - SLsmg_draw_object (h->y + line + 2, h->x + col + 2, acs_map[c]); +#if defined(UTF8) && SLANG_VERSION < 20000 + SLsmg_draw_object (h->y + line + 2, h->x + col + 2, acs_map [c]); +#else + SLsmg_draw_object (h->y + line + 2, h->x + col + 2, c); +#endif /* UTF8 */ #endif } else { #ifdef UTF8 --- src/myslang.h +++ src/myslang.h @@ -11,6 +11,12 @@ #endif /* HAVE_SLANG_SLANG_H */ #endif +#if SLANG_VERSION >= 20000 +#define UTF8 1 +#define SLsmg_Is_Unicode SLsmg_is_utf8_mode() +void SLsmg_write_nwchars(wchar_t *s, size_t n); +#endif + #ifdef UTF8 # include #endif --- src/slint.c +++ src/slint.c @@ -181,6 +181,10 @@ SLtt_get_terminfo (); +#if SLANG_VERSION >= 20000 + SLutf8_enable (-1); +#endif + /* * If the terminal in not in terminfo but begins with a well-known * string such as "linux" or "xterm" S-Lang will go on, but the --- src/util.c +++ src/util.c @@ -55,6 +55,32 @@ static const char app_text [] = "Midnight-Commander"; int easy_patterns = 1; +#if SLANG_VERSION >= 20000 +void SLsmg_write_nwchars(wchar_t *s, size_t n) +{ + if (SLsmg_is_utf8_mode()) { /* slang can handle it directly */ + while(n-- && *s) + SLsmg_write_char(*s++); + } + else { /* convert wchars back to 8bit encoding */ + mbstate_t mbs; + memset (&mbs, 0, sizeof (mbs)); + while (n-- && *s) { + char buf[MB_LEN_MAX + 1]; /* should use 1 char, but to be sure */ + if (*s < 0x80) { + SLsmg_write_char(*s++); /* ASCII */ + } + else { + if (wcrtomb(buf, *s++, &mbs) == 1) + SLsmg_write_char((wchar_t)(buf[0])); + else + SLsmg_write_char('?'); /* should not happen */ + } + } + } +} +#endif + extern void str_replace(char *s, char from, char to) { for (; *s != '\0'; s++) {