detect_obj_init(3)
π NAME π
detect_obj_init β bestie, this is the one that gets your DetectObject structure all set up and ready to slay β¨
π¦ SYNOPSIS π¦
#include <chardet.h>
DetectObj chardet_obj_init (void);
πΈ DESCRIPTION πΈ
Okay so real talk: detect_obj_init initializes the DetectObj structure β the lil container that's holding all your chardet info. You literally cannot start the party without it, no cap. It sets up the struct so it's ready to store what chardet finds out about your text π
π RETURN VALUE π
It returns a DetectObject structure. That's the good news.
The important part though? The return value must be freed by the chardet_obj_free api. Like, do not ghost that step, bestie β if you don't free it, that's a leak and we don't do leaks in this house π«Ά
Here's the struct you're getting, in all its glory:
typedef struct DetectObject {
char * encoding;
float confidence;
short bom;
} DetectObj;
β¨ EXAMPLE β¨
Here's the whole vibe, copy-paste ready:
#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;
}
# 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);
return 0;
}
π AUTHORS π
JoungKyun.Kim <http://oops.org> β iconic behavior, honestly π
π BUG REPORTS π
Found something cursed? Use the QnA board on https://github.com/Joungkyun/libchardet/issues β go tell them, fr fr π
π SEE ALSO π
And that's the whole page, bestie π§β¨ this was the detect_obj_init(3) page from the libchardet manuals, dated 2019-08-01 β go forth and detect responsibly π
π¦ where this page comes from
- debian trixie: libchardet-dev 1.0.6-1 Β· MPL-1.1 OR GPL-2.0-or-later OR LGPL-2.1-or-later
- ubuntu questing: libchardet-dev 1.0.6-1
- ubuntu resolute: libchardet-dev 1.0.6-2 Β· MPL-1.1 OR GPL-2.0-or-later OR LGPL-2.1-or-later
- ubuntu stonking: libchardet-dev 1.0.6-2 Β· MPL-1.1 OR GPL-2.0-or-later OR LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms