experimenting with mblen

This commit is contained in:
Mohit Rathore 2017-08-29 00:04:48 +05:30
parent 2e33c577b1
commit 49ae9b655a

13
nnn.c
View file

@ -1189,6 +1189,7 @@ unescape(const char *str)
static void static void
printent(struct entry *ent, int sel) printent(struct entry *ent, int sel)
{ {
return;
static int ncols; static int ncols;
if (PATH_MAX + 16 < COLS) if (PATH_MAX + 16 < COLS)
@ -1274,7 +1275,17 @@ printent_long(struct entry *ent, int sel)
else if (ent->mode & 0100) else if (ent->mode & 0100)
snprintf(g_buf, ncols, "%s%-16.16s %8.8s* %s*", CURSYM(sel), buf, coolsize(ent->size), unescape(ent->name)); snprintf(g_buf, ncols, "%s%-16.16s %8.8s* %s*", CURSYM(sel), buf, coolsize(ent->size), unescape(ent->name));
else else
snprintf(g_buf, ncols, "%s%-16.16s %8.8s %s", CURSYM(sel), buf, coolsize(ent->size), unescape(ent->name)); {
// experimenting in this section
const char *c = unescape(ent->name);
unsigned int i;
int count=0;
for(i=0;i<strlen(c);i++)
count+=mblen(c+i, MB_CUR_MAX);
snprintf(g_buf, ncols, "%s%-16.16s %8.8s %s--%d", CURSYM(sel), buf, coolsize(ent->size), unescape(ent->name), count);
}
} else { } else {
if (S_ISDIR(ent->mode)) if (S_ISDIR(ent->mode))
snprintf(g_buf, ncols, "%s%-16.16s %8.8s/ %s/", CURSYM(sel), buf, coolsize(ent->blocks << 9), unescape(ent->name)); snprintf(g_buf, ncols, "%s%-16.16s %8.8s/ %s/", CURSYM(sel), buf, coolsize(ent->blocks << 9), unescape(ent->name));