Windows: use wcsftime instead of strftime
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
#ifdef BUILDING_RECOLL
|
||||
#include "autoconfig.h"
|
||||
#include "transcode.h"
|
||||
#else
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
#include "md5ut.h"
|
||||
#include "log.h"
|
||||
#include "smallut.h"
|
||||
#include "rclconfig.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -277,6 +278,23 @@ string url_gpathS(const string& url)
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string utf8datestring(const std::string& format, struct tm *tm)
|
||||
{
|
||||
string u8date;
|
||||
#ifdef _WIN32
|
||||
wchar_t wformat[200];
|
||||
utf8towchar(format, wformat, 199);
|
||||
wchar_t wdate[250];
|
||||
wcsftime(wdate, 250, wformat, tm);
|
||||
wchartoutf8(wformat, u8date);
|
||||
#else
|
||||
char datebuf[200];
|
||||
strftime(datebuf, 199, format.c_str(), tm);
|
||||
transcode(datebuf, u8date, RclConfig::getLocaleCharset(), "UTF-8");
|
||||
#endif
|
||||
return u8date;
|
||||
}
|
||||
|
||||
const string& tmplocation()
|
||||
{
|
||||
static string stmpdir;
|
||||
|
||||
@@ -47,6 +47,10 @@ extern bool printableUrl(const std::string& fcharset,
|
||||
/// "/c/" This should be used only for splitting the path in rcldb.
|
||||
extern std::string url_gpathS(const std::string& url);
|
||||
|
||||
/// Like strftime but guaranteed utf-8 output (esp. useful on Windows)
|
||||
struct tm;
|
||||
extern std::string utf8datestring(const std::string& format, struct tm *tm);
|
||||
|
||||
/// Retrieve the temp dir location: $RECOLL_TMPDIR else $TMPDIR else /tmp
|
||||
extern const std::string& tmplocation();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user