detect_init(3)

detect_init3

Initialize detect structure

Snopsis

#include <chardet.h>
Detect * chardet_init (void);

Overview

initialize Detect structure.

Return value

Returns NULL on false and returns Detect structure on success.

	typedef struct Detect_t {
		Detector *detect;
	} Detect;

Examples

#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;
	}
	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;
	}
	# check support obj->bom with CHARDET_BOM_CHECK constant
	printf ("encoding: %s, confidence: %f, exists bom: %d\n", obj->encoding, obj->confidence, obj->bom);
	detect_obj_free (&obj);
	detect_destroy (&d);
    return 0;
}

Releases

6 releases since Debian 9 (Stretch); the text changed 2 times.

  1. 9–12
  2. 13
  3. Arch

Authors

JoungKyun.Kim <http://oops.org>

Bug reports

Use QnA board on https://github.com/Joungkyun/libchardet/issues

From libchardet 1.0.6-4 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.