From c7e5aefe17861ff6bf600278a33168a62ee2e0cf Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Fri, 2 Mar 2007 16:20:03 +0000 Subject: [PATCH] UTF-8 file listings --- ChangeLog | 4 ++-- mbsebbs/file.c | 18 ++++++++++++++---- mbsebbs/filesub.c | 13 ++++++++----- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index d0492570..93a4c5a2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -36,8 +36,8 @@ v0.91.5 18-Feb-2007 Email and FTN mail reading now translates to the users characterset using glibc iconv. Changed menus lastcallers, whoson, userlist, pinfo, fsedit, - timestats to output UTF-8 code if the user has set that terminal - setting. + timestats, filelist to output UTF-8 code if the user has set + that terminal setting. mbfile: The index command produces UTF-8 webpages. diff --git a/mbsebbs/file.c b/mbsebbs/file.c index 9bf36087..1e0861a7 100644 --- a/mbsebbs/file.c +++ b/mbsebbs/file.c @@ -4,7 +4,7 @@ * Purpose ...............: All the file functions. * ***************************************************************************** - * Copyright (C) 1997-2005 + * Copyright (C) 1997-2007 * * Michiel Broek FIDO: 2:280/2802 * Beekmansbos 10 @@ -111,10 +111,14 @@ void File_List() if ((fdb_area = mbsedb_OpenFDB(iAreaNumber, 30)) == NULL) return; + if (utf8) + chartran_init((char *)"CP437", (char *)"UTF-8", 'b'); + clear(); Header(); if (iLC(2) == 1) { mbsedb_CloseFDB(fdb_area); + chartran_close(); return; } @@ -124,11 +128,12 @@ void File_List() T.Active = FALSE; T.Size = fdb.Size; strncpy(T.SFile, fdb.Name, 12); - strncpy(T.LFile, fdb.LName, 80); + strncpy(T.LFile, chartran(fdb.LName), 80); SetTag(T); if (ShowOneFile() == 1) { mbsedb_CloseFDB(fdb_area); + chartran_close(); return; } @@ -150,6 +155,7 @@ void File_List() snprintf(temp, 81, "%s%d / %d bytes", (char *) Language(242), FileCount, FileBytes); pout(LIGHTCYAN, BLACK, temp); Enter(2); + chartran_close(); iLineCount = 0; mbsedb_CloseFDB(fdb_area); @@ -432,11 +438,14 @@ void File_RawDir(char *OpData) Enter(2); Pause(); } else { + if (utf8) + chartran_init((char *)"CP437", (char *)"UTF-8", 'b'); + clear(); /* Filename Size Date */ pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(261)); Enter(1); - fLine(78); + PUTSTR(chartran(fLine_str(78))); while ((dp = readdir( dirp )) != NULL ) { snprintf(FileName, PATH_MAX, "%s/%s", temp, dp->d_name); @@ -469,7 +478,7 @@ void File_RawDir(char *OpData) } colour(CFG.HiliteF, CFG.HiliteB); - fLine(78); + PUTSTR(chartran(fLine_str(78))); /* Total Files: */ /* Bytes */ snprintf(temp2, 81, "%s %d, %d %s", (char *) Language(242), iFileCount, iBytes, (char *) Language(354)); pout(LIGHTGREEN, BLACK, temp2); @@ -477,6 +486,7 @@ void File_RawDir(char *OpData) Pause(); closedir(dirp); + chartran_close(); } free(temp); diff --git a/mbsebbs/filesub.c b/mbsebbs/filesub.c index 011cfb06..6ef46e8f 100644 --- a/mbsebbs/filesub.c +++ b/mbsebbs/filesub.c @@ -172,7 +172,8 @@ void Header() Enter(1); colour(WHITE, BLACK); - fLine(79); + PUTSTR(chartran(fLine_str(79))); + iLineCount++; } @@ -391,11 +392,13 @@ int ShowOneFile() else fg = (int)fdb.Desc[z][3] - 48; bg = (int)fdb.Desc[z][2] - 48; - snprintf(temp, 81, " %s",fdb.Desc[z]+4); - pout(fg, bg, temp); + colour(fg, bg); + PUTSTR((char *)" "); + PUTSTR(chartran(fdb.Desc[z]+4)); } else { - snprintf(temp, 81, " %s",fdb.Desc[z]); - pout(CFG.FiledescF, CFG.FiledescB, temp); + colour(CFG.FiledescF, CFG.FiledescB); + PUTSTR((char *)" "); + PUTSTR(chartran(fdb.Desc[z])); } Enter(1);