diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 21:30:40 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 21:30:40 +0000 |
commit | 133a45c109da5310add55824db21af5239951f93 (patch) | |
tree | ba6ac4c0a950a0dda56451944315d66409923918 /contrib/google-ced/ced_c.cc | |
parent | Initial commit. (diff) | |
download | rspamd-133a45c109da5310add55824db21af5239951f93.tar.xz rspamd-133a45c109da5310add55824db21af5239951f93.zip |
Adding upstream version 3.8.1.upstream/3.8.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'contrib/google-ced/ced_c.cc')
-rw-r--r-- | contrib/google-ced/ced_c.cc | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/contrib/google-ced/ced_c.cc b/contrib/google-ced/ced_c.cc new file mode 100644 index 0000000..5167121 --- /dev/null +++ b/contrib/google-ced/ced_c.cc @@ -0,0 +1,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; +} |