Recoll windows build: adjust to pathut wchar-utf8 changes

This commit is contained in:
Jean-Francois Dockes 2020-05-11 07:02:46 +01:00
parent 0379d4fd61
commit 631532f100
4 changed files with 16 additions and 69 deletions

View File

@ -47,6 +47,13 @@
#include "pathut.h"
#include "smallut.h"
#ifdef MDU_INCLUDE_LOG
#include MDU_INCLUDE_LOG
#else
#include "log.h"
#endif
#include <cstdlib>
#include <cstring>
#include <dirent.h>
@ -118,6 +125,12 @@
#define ftruncate _chsize_s
#ifdef _MSC_VER
// For getpid
#include <process.h>
#define getpid _getpid
#endif
#else /* !_WIN32 -> */
#include <unistd.h>
@ -144,13 +157,6 @@
#endif /* !_WIN32 */
#include "smallut.h"
#ifdef MDU_INCLUDE_LOG
#include MDU_INCLUDE_LOG
#else
#include "log.h"
#endif
using namespace std;
#ifdef _WIN32

View File

@ -23,7 +23,6 @@
#include <errno.h>
#include <iconv.h>
#include <wchar.h>
#include "transcode.h"
#include "log.h"
@ -153,55 +152,3 @@ error:
return ret;
}
bool wchartoutf8(const wchar_t *in, std::string& out)
{
static iconv_t ic = (iconv_t)-1;
if (ic == (iconv_t)-1) {
if((ic = iconv_open("UTF-8", "WCHAR_T")) == (iconv_t)-1) {
LOGERR("wchartoutf8: iconv_open failed\n");
return false;
}
}
const int OBSIZ = 8192;
char obuf[OBSIZ], *op;
out.erase();
size_t isiz = 2 * wcslen(in);
out.reserve(isiz);
const char *ip = (const char *)in;
while (isiz > 0) {
size_t osiz;
op = obuf;
osiz = OBSIZ;
if(iconv(ic, (ICONV_CONST char **)&ip, &isiz, &op, &osiz) == (size_t)-1
&& errno != E2BIG) {
LOGERR("wchartoutf8: iconv error, errno: " << errno << endl);
return false;
}
out.append(obuf, OBSIZ - osiz);
}
return true;
}
bool utf8towchar(const std::string& in, wchar_t *out, size_t obytescap)
{
static iconv_t ic = (iconv_t)-1;
if (ic == (iconv_t)-1) {
if((ic = iconv_open("WCHAR_T", "UTF-8")) == (iconv_t)-1) {
LOGERR("utf8towchar: iconv_open failed\n");
return false;
}
}
size_t isiz = in.size();
const char *ip = in.c_str();
size_t osiz = (size_t)obytescap-2;
char *op = (char *)out;
if (iconv(ic, (ICONV_CONST char **)&ip, &isiz, &op, &osiz) == (size_t)-1) {
LOGERR("utf8towchar: iconv error, errno: " << errno << endl);
return false;
}
*op++ = 0;
*op = 0;
return true;
}

View File

@ -16,10 +16,9 @@
*/
#ifndef _TRANSCODE_H_INCLUDED_
#define _TRANSCODE_H_INCLUDED_
/**
*
*/
#include <string>
/**
* c++ized interface to iconv
*
@ -36,9 +35,4 @@ extern bool transcode(const std::string &in, std::string &out,
const std::string &ocode,
int *ecnt = 0);
#ifdef _WIN32
extern bool wchartoutf8(const wchar_t *in, std::string& out);
extern bool utf8towchar(const std::string& in, wchar_t *out, size_t obytescap);
#endif
#endif /* _TRANSCODE_H_INCLUDED_ */

View File

@ -2,7 +2,7 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "Recoll"
#define MyAppVersion "1.27.0-20200407-wip"
#define MyAppVersion "1.27.1-20200511-d8edbcbc"
#define MyAppPublisher "Recoll.org"
#define MyAppURL "http://www.recoll.org"
#define MyAppExeName "recoll.exe"