Switch to unified view

a/src/internfile/mh_exec.cpp b/src/internfile/mh_exec.cpp
1
#ifndef lint
1
#ifndef lint
2
static char rcsid[] = "@(#$Id: mh_exec.cpp,v 1.13 2008-10-06 06:22:46 dockes Exp $ (C) 2005 J.F.Dockes";
2
static char rcsid[] = "@(#$Id: mh_exec.cpp,v 1.14 2008-10-09 09:19:37 dockes Exp $ (C) 2005 J.F.Dockes";
3
#endif
3
#endif
4
/*
4
/*
5
 *   This program is free software; you can redistribute it and/or modify
5
 *   This program is free software; you can redistribute it and/or modify
6
 *   it under the terms of the GNU General Public License as published by
6
 *   it under the terms of the GNU General Public License as published by
7
 *   the Free Software Foundation; either version 2 of the License, or
7
 *   the Free Software Foundation; either version 2 of the License, or
...
...
22
#include "mh_exec.h"
22
#include "mh_exec.h"
23
#include "mh_html.h"
23
#include "mh_html.h"
24
#include "debuglog.h"
24
#include "debuglog.h"
25
#include "cancelcheck.h"
25
#include "cancelcheck.h"
26
#include "smallut.h"
26
#include "smallut.h"
27
#include "transcode.h"
27
28
28
#include <sys/types.h>
29
#include <sys/types.h>
29
#include <sys/wait.h>
30
#include <sys/wait.h>
30
31
31
#ifndef NO_NAMESPACES
32
#ifndef NO_NAMESPACES
...
...
104
        }           
105
        }           
105
    }
106
    }
106
    return false;
107
    return false;
107
    }
108
    }
108
109
110
    // if output is text, we must handle the conversion to utf-8
111
    string charset = cfgCharset.empty() ? "utf-8" : cfgCharset;
112
    string mt = cfgMtype.empty() ? "text/html" : cfgMtype;
113
    if (!mt.compare("text/plain") && charset.compare("utf-8")) {
114
  string transcoded;
115
  int ecnt;
116
  if (!transcode(output, transcoded, charset, "UTF-8", &ecnt)) {
117
      LOGERR(("mh_exec: transcode failed from [%s] to UTF-8\n",
118
          charset.c_str()));
119
  } else {
120
      if (ecnt) {
121
      LOGDEB(("mh_exec: %d transcoding errors  from [%s] to UTF-8\n",
122
          ecnt, charset.c_str()));
123
      }
124
      output = transcoded;
125
  }
126
    }
109
    // Success. Store some external metadata
127
    // Success. Store some external metadata
110
    m_metaData["origcharset"] = m_defcharset;
128
    m_metaData["origcharset"] = m_defcharset;
111
    // Default charset: all recoll filters output utf-8, but this
129
    // Default charset: all recoll filters output utf-8, but this
112
    // could still be overridden by the content-type meta tag.
130
    // could still be overridden by the content-type meta tag.
113
    m_metaData["charset"] = cfgCharset.empty() ? "utf-8" : cfgCharset;
131
    m_metaData["charset"] = charset;
114
    m_metaData["mimetype"] = cfgMtype.empty() ? "text/html" : cfgMtype;
132
    m_metaData["mimetype"] = mt;
115
    return true;
133
    return true;
116
}
134
}