Some common stuff used by other UTF-8 patches. diff -Naurdp mc-4.6.1.orig/src/util.c mc-4.6.1/src/util.c --- mc-4.6.1.orig/src/util.c 2005-09-05 17:08:08.000000000 +0200 +++ mc-4.6.1/src/util.c 2005-09-05 17:08:00.000000000 +0200 @@ -113,6 +113,30 @@ mbstrlen (const char *str) return strlen (str); } +int +columns_to_bytes (const char *str, int col) +{ + int bytes = 0; + int columns = 0; + int i; +#ifdef UTF8 + if (SLsmg_Is_Unicode) { + static mbstate_t s; + while (columns < col) { + memset (&s, 0, sizeof (s)); + i = mbrlen (str + bytes, -1, &s); + if (i <= 0) { + return col + bytes - columns; + } + bytes += i; + columns ++; + } + return col + bytes - columns; + } else +#endif + return col; +} + #ifdef UTF8 void diff -Naurdp mc-4.6.1.orig/src/util.h mc-4.6.1/src/util.h --- mc-4.6.1.orig/src/util.h 2005-09-05 17:08:08.000000000 +0200 +++ mc-4.6.1/src/util.h 2005-09-05 17:08:00.000000000 +0200 @@ -95,6 +95,7 @@ char *get_owner (int); void fix_utf8(char *str); size_t mbstrlen (const char *); +int columns_to_bytes (const char *, int); wchar_t *mbstr_to_wchar (const char *); char *wchar_to_mbstr (const wchar_t *); char *utf8_to_local(char *str);