Windows: text/plain: check if already utf-8 before trying transcode
This commit is contained in:
parent
d9c1a9648c
commit
cca69cbd31
@ -24,6 +24,10 @@
|
|||||||
#include "smallut.h"
|
#include "smallut.h"
|
||||||
#include "listmem.h"
|
#include "listmem.h"
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include "utf8iter.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
// Called after decoding from utf-8 failed. Handle the common case
|
// Called after decoding from utf-8 failed. Handle the common case
|
||||||
@ -111,6 +115,17 @@ bool RecollFilter::txtdcode(const string& who)
|
|||||||
int ecnt;
|
int ecnt;
|
||||||
string otext;
|
string otext;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
// Under Windows the environment charset will usually not be
|
||||||
|
// utf-8. We check if the text is actually utf-8. This is worth
|
||||||
|
// it, else the conversion from 8-bit is going to succeed if the
|
||||||
|
// text is already utf-8, and produce bogus data.
|
||||||
|
if (utf8check(itext, otext) >= 0) {
|
||||||
|
m_metaData[cstr_dj_keycharset] = cstr_utf8;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
string bomfromcode = bomtocode(itext);
|
string bomfromcode = bomtocode(itext);
|
||||||
if (!bomfromcode.empty()) {
|
if (!bomfromcode.empty()) {
|
||||||
LOGDEB(who << "::txtdcode: " << " input charset changed from " <<
|
LOGDEB(who << "::txtdcode: " << " input charset changed from " <<
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user