エンコーディング検出ライブラリ「encdet」をリリース
さて、久しぶりなわけですが。
タイトルの通りリリースしました。
http://wiki.github.com/spiritloose/encdet
http://github.com/spiritloose/encdet/tree/master
Mozillaの「Mozilla Universal Charset Detector」というやつのCバインディングです。
MozillaのMercurialリポジトリからコピってきて、Cのインターフェースをつけてautotools化してみました。
http://www.void.in/wiki/Universalchardet っていうのもあったんですが、本家の方が結構変わってたり、
autotools化したかったり、もろもろあったので作りました。
#include <encdet.h> #include <string.h> #include <stdio.h> int main(int argc, char **argv) { char buf[BUFSIZ]; const char *encoding; encdet_t det = encdet_new(ENCDET_ALL); while ((fgets(buf, sizeof(buf), stdin)) != NULL) { encdet_handle_data(det, buf, strlen(buf)); } encdet_data_end(det); encoding = encdet_get_result(det); if (encoding) { puts(encoding); } else { puts("UNKNOWN"); } encdet_destroy(det); return 0; }
みたいな感じです。
メンテは、本家に追従していく予定です。