summaryrefslogtreecommitdiffstats
path: root/contrib/google-ced/ced_c.cc
blob: 51671218bb1e5dba8735d08b0c986e3e5618906a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "ced_c.h"
#include "compact_enc_det.h"

const char* ced_encoding_detect(const char* text, int text_length,
								const char* url_hint,
								const char* http_charset_hint,
								const char* meta_charset_hint,
								const int encoding_hint,
								CedTextCorpusType corpus_type, bool ignore_7bit_mail_encodings,
								int* bytes_consumed, bool* is_reliable)
{
	CompactEncDet::TextCorpusType ct = CompactEncDet::NUM_CORPA;

	ct = static_cast<CompactEncDet::TextCorpusType>(corpus_type);

	auto enc = CompactEncDet::DetectEncoding(text, text_length, url_hint,
			http_charset_hint, meta_charset_hint, encoding_hint, default_language(),
			ct, ignore_7bit_mail_encodings, bytes_consumed, is_reliable);

	if (IsValidEncoding(enc)) {
		return MimeEncodingName(enc);
	}

	return nullptr;
}