Encode strftime output into utf-8 before displaying in GUI
This commit is contained in:
parent
1d51eff4d8
commit
bfb0f4c03b
@ -520,6 +520,11 @@ vector<string> RclConfig::getTopdirs() const
|
|||||||
return tdl;
|
return tdl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const string& RclConfig::getLocaleCharset()
|
||||||
|
{
|
||||||
|
return o_localecharset;
|
||||||
|
}
|
||||||
|
|
||||||
// Get charset to be used for transcoding to utf-8 if unspecified by doc
|
// Get charset to be used for transcoding to utf-8 if unspecified by doc
|
||||||
// For document contents:
|
// For document contents:
|
||||||
// If defcharset was set (from the config or a previous call, this
|
// If defcharset was set (from the config or a previous call, this
|
||||||
|
|||||||
@ -239,6 +239,9 @@ class RclConfig {
|
|||||||
static bool valueSplitAttributes(const string& whole, string& value,
|
static bool valueSplitAttributes(const string& whole, string& value,
|
||||||
ConfSimple& attrs) ;
|
ConfSimple& attrs) ;
|
||||||
|
|
||||||
|
/** Return the locale's character set */
|
||||||
|
static const std::string& getLocaleCharset();
|
||||||
|
|
||||||
/** Return icon path for mime type and tag */
|
/** Return icon path for mime type and tag */
|
||||||
string getMimeIconPath(const string &mt, const string& apptag) const;
|
string getMimeIconPath(const string &mt, const string& apptag) const;
|
||||||
|
|
||||||
|
|||||||
@ -49,6 +49,7 @@
|
|||||||
#include "rclmain_w.h"
|
#include "rclmain_w.h"
|
||||||
#include "multisave.h"
|
#include "multisave.h"
|
||||||
#include "appformime.h"
|
#include "appformime.h"
|
||||||
|
#include "transcode.h"
|
||||||
|
|
||||||
static const QKeySequence quitKeySeq("Ctrl+q");
|
static const QKeySequence quitKeySeq("Ctrl+q");
|
||||||
static const QKeySequence closeKeySeq("Ctrl+w");
|
static const QKeySequence closeKeySeq("Ctrl+w");
|
||||||
@ -177,15 +178,17 @@ static string sizegetter(const string& fld, const Rcl::Doc& doc)
|
|||||||
|
|
||||||
static string dategetter(const string&, const Rcl::Doc& doc)
|
static string dategetter(const string&, const Rcl::Doc& doc)
|
||||||
{
|
{
|
||||||
char datebuf[100];
|
string sdate;
|
||||||
datebuf[0] = 0;
|
|
||||||
if (!doc.dmtime.empty() || !doc.fmtime.empty()) {
|
if (!doc.dmtime.empty() || !doc.fmtime.empty()) {
|
||||||
|
char datebuf[100];
|
||||||
|
datebuf[0] = 0;
|
||||||
time_t mtime = doc.dmtime.empty() ?
|
time_t mtime = doc.dmtime.empty() ?
|
||||||
atoll(doc.fmtime.c_str()) : atoll(doc.dmtime.c_str());
|
atoll(doc.fmtime.c_str()) : atoll(doc.dmtime.c_str());
|
||||||
struct tm *tm = localtime(&mtime);
|
struct tm *tm = localtime(&mtime);
|
||||||
strftime(datebuf, 99, "%Y-%m-%d", tm);
|
strftime(datebuf, 99, "%Y-%m-%d", tm);
|
||||||
|
transcode(datebuf, sdate, RclConfig::getLocaleCharset(), "UTF-8");
|
||||||
}
|
}
|
||||||
return datebuf;
|
return sdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
static string datetimegetter(const string&, const Rcl::Doc& doc)
|
static string datetimegetter(const string&, const Rcl::Doc& doc)
|
||||||
@ -196,7 +199,7 @@ static string datetimegetter(const string&, const Rcl::Doc& doc)
|
|||||||
time_t mtime = doc.dmtime.empty() ?
|
time_t mtime = doc.dmtime.empty() ?
|
||||||
atoll(doc.fmtime.c_str()) : atoll(doc.dmtime.c_str());
|
atoll(doc.fmtime.c_str()) : atoll(doc.dmtime.c_str());
|
||||||
struct tm *tm = localtime(&mtime);
|
struct tm *tm = localtime(&mtime);
|
||||||
strftime(datebuf, 99, "%Y-%m-%d %H:%M:%S %z", tm);
|
strftime(datebuf, 99, prefs.creslistdateformat.c_str(), tm);
|
||||||
}
|
}
|
||||||
return datebuf;
|
return datebuf;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,6 +37,7 @@ using std::list;
|
|||||||
#include "rclutil.h"
|
#include "rclutil.h"
|
||||||
#include "plaintorich.h"
|
#include "plaintorich.h"
|
||||||
#include "mimehandler.h"
|
#include "mimehandler.h"
|
||||||
|
#include "transcode.h"
|
||||||
|
|
||||||
// Default highlighter. No need for locking, this is query-only.
|
// Default highlighter. No need for locking, this is query-only.
|
||||||
static const string cstr_hlfontcolor("<span style='color: blue;'>");
|
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;
|
int docnumforlinks = m_winfirst + 1 + i;
|
||||||
sprintf(numbuf, "%d", docnumforlinks);
|
sprintf(numbuf, "%d", docnumforlinks);
|
||||||
|
|
||||||
// Document date: either doc or file modification time
|
// Document date: either doc or file modification times
|
||||||
char datebuf[100];
|
string datebuf;
|
||||||
datebuf[0] = 0;
|
|
||||||
if (!doc.dmtime.empty() || !doc.fmtime.empty()) {
|
if (!doc.dmtime.empty() || !doc.fmtime.empty()) {
|
||||||
|
char cdate[100];
|
||||||
|
cdate[0] = 0;
|
||||||
time_t mtime = doc.dmtime.empty() ?
|
time_t mtime = doc.dmtime.empty() ?
|
||||||
atoll(doc.fmtime.c_str()) : atoll(doc.dmtime.c_str());
|
atoll(doc.fmtime.c_str()) : atoll(doc.dmtime.c_str());
|
||||||
struct tm *tm = localtime(&mtime);
|
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
|
// Size information. We print both doc and file if they differ a lot
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user