Clone this repo:

Branches

  1. 910cca2 Fix crash detected by asan test by Jinsuk Kim · 4 weeks ago master
  2. e21eb6a Post-detection mapping for HTML5 mode by Jinsuk Kim · 4 months ago
  3. 368a9cc Merge pull request #4 from randomascii/master by JinsukKim · 6 months ago
  4. 9a5abb8 Save 908,288 bytes by deleting 'const' three times by Bruce Dawson · 6 months ago
  5. e57cdc4 Merge pull request #3 from sgraham/master by Jinsuk Kim · 7 months ago

Introduction

Compact Encoding Detection(CED for short) is a library written in C++ that scans given raw bytes and detect the most likely text encoding.

Basic usage:

#include "compact_enc_det/compact_enc_det.h"

const char* text = "Input text";
bool is_reliable;
int bytes_consumed;

Encoding encoding = CompactEncDet::DetectEncoding(
        text, strlen(text),
        nullptr, nullptr, nullptr,
        UNKNOWN_ENCODING,
        UNKNOWN_LANGUAGE,
        CompactEncDet::WEB_CORPUS,
        false,
        &bytes_consumed,
        &is_reliable);

How to build

You need CMake to build the package. After unzipping the source code , run autogen.sh to build everything automatically. The script also downloads Google Test framework needed to build the unittest.

$ cd compact_enc_det
$ ./autogen.sh
...
$ bin/ced_unittest

On Windows, run cmake . to download the test framework, and generate project files for Visual Studio.

D:\packages\compact_enc_det> cmake .