Copyright © 2015 JoungKyun.Kim All rights reserved.
Abstract
Determine the charset of the input data with Mozilla Universal Charset Detection
This project move to GitHUB. After 10 seconds, redirect to GitHUB project page.
Repository https://github.com/Joungkyun/libchardet
Download
This download page is deprecated. Move to https://github.com/Joungkyun/libchardet/releases
libchardet-1.0.6.tar.bz2
1.0.5.tar.bz2
libchardet-1.0.4.tar.bz2
libchardet-1.0.3.tar.bz2
libchardet-1.0.2.tar.bz2
libchardet-1.0.1.tar.bz2
libchardet-1.0.0.tar.bz2
If you want to download with wget, don't use default user-agent of wget! (Use -U option)
Samples
See also test directory of source code
#include <chardet.h> int main (void) { DetectObj *obj; if ( (obj = detect_obj_init ()) == NULL ) { fprintf (stderr, "Memory Allocation failed\n"); return CHARDET_MEM_ALLOCATED_FAIL; } switch (detect ("안녕하세요", &obj)) { case CHARDET_OUT_OF_MEMORY : fprintf (stderr, "On handle processing, occured out of memory\n"); detect_obj_free (&obj); return CHARDET_OUT_OF_MEMORY; case CHARDET_NULL_OBJECT : fprintf (stderr, "2st argument of chardet() is must memory allocation " "with detect_obj_init API\n"); return CHARDET_NULL_OBJECT; } printf ("encoding: %s, confidence: %f\n", obj->encoding, obj->confidence); detect_obj_free (&obj); return 0; }
or
#include <chardet.h> int main (void) { Detect * d; DetectObj * obj; if ( (d = detect_init ()) == NULL ) { fprintf (stderr, "chardet handle initialize failed\n"); return CHARDET_MEM_ALLOCATED_FAIL; } // for loop //detect_reset (&d); if ( (obj = detect_obj_init ()) == NULL ) { fprintf (stderr, "Memory Allocation failed\n"); return CHARDET_MEM_ALLOCATED_FAIL; } switch (detect_handledata (&d, "안녕하세요", &obj)) { case CHARDET_OUT_OF_MEMORY : fprintf (stderr, "On handle processing, occured out of memory\n"); detect_obj_free (&obj); return CHARDET_OUT_OF_MEMORY; case CHARDET_NULL_OBJECT : fprintf (stderr, "2st argument of chardet() is must memory allocation " "with detect_obj_init API\n"); return CHARDET_NULL_OBJECT; } printf ("encoding: %s, confidence: %f\n", obj->encoding, obj->confidence); detect_obj_free (&obj); detect_destroy (&d); return 0; }
Copyright & License
Copyright (c) 2015 JoungKyun.Kim <http://oops.org> All rights reserved. This program is under MPL 1.1 or LGPL 2.1 Original Code is Perl Encode::Detect-1.01 by John Gardiner Myers <jgmyers@proofpoint.com>