Encode strftime output into utf-8 before displaying in GUI

This commit is contained in:
Jean-Francois Dockes
2016-08-06 15:01:34 +02:00
parent 1d51eff4d8
commit bfb0f4c03b
4 changed files with 22 additions and 8 deletions
+7 -4
View File
@@ -37,6 +37,7 @@ using std::list;
#include "rclutil.h"
#include "plaintorich.h"
#include "mimehandler.h"
#include "transcode.h"
// Default highlighter. No need for locking, this is query-only.
static const string cstr_hlfontcolor("<span style='color: blue;'>");
@@ -191,14 +192,16 @@ void ResListPager::displayDoc(RclConfig *config, int i, Rcl::Doc& doc,
int docnumforlinks = m_winfirst + 1 + i;
sprintf(numbuf, "%d", docnumforlinks);
// Document date: either doc or file modification time
char datebuf[100];
datebuf[0] = 0;
// Document date: either doc or file modification times
string datebuf;
if (!doc.dmtime.empty() || !doc.fmtime.empty()) {
char cdate[100];
cdate[0] = 0;
time_t mtime = doc.dmtime.empty() ?
atoll(doc.fmtime.c_str()) : atoll(doc.dmtime.c_str());
struct tm *tm = localtime(&mtime);
strftime(datebuf, 99, dateFormat().c_str(), tm);
strftime(cdate, 99, dateFormat().c_str(), tm);
transcode(cdate, datebuf, RclConfig::getLocaleCharset(), "UTF-8");
}
// Size information. We print both doc and file if they differ a lot