Man page - detect_handledata(3)

Packages contains this manual

Available languages:

en ko

Manual

detect_handledata

์ด ๋ฆ„
์‚ฌ ์šฉ ๋ฒ•
์„ค ๋ช…
API ์•„ ๊ทœ ๋จผ ํŠธ
๋ฐ˜ ํ™˜ ๊ฐ’
์˜ˆ ์ œ
์ € ์ž
๋ฒ„ ๊ทธ ๋ฆฌ ํฌ ํŠธ
์ฐธ ๊ณ 

์ด ๋ฆ„

detect_handledata, detect_handledata_r - ๋ฌธ ์ž ์…‹ ๊ณผ ์ • ํ™• ๋„ ๋ฅผ ์ธก ์ •

์‚ฌ ์šฉ ๋ฒ•

#include <chardet.h>

short detect_handledata (Detect ** handle, const char * inbuf, DetectObj ** outbuf);

short detect_handledata_r (Detect ** handle, const char * inbuf, size_t inlen, DetectObj ** outbuf);

์„ค ๋ช…

inbuf ์˜ ๋ฌธ ์ž ์…‹ ๊ณผ ์ • ํ™• ๋„ ๋ฅผ outbuf์— ์ € ์žฅ ํ•œ ๋‹ค .

detect_handledata API๋Š” binary safe ๋ฌธ ์ œ ๋กœ ๋” ์ด ์ƒ ์‚ฌ ์šฉ ์„ ๊ถŒ ์žฅ ํ•˜ ์ง€ ์•Š ์Šต ๋‹ˆ ๋‹ค . detect_handledata_r API๋ฅผ ์ด ์šฉ ํ•˜ ์‹ญ ์‹œ ์˜ค .

API ์•„ ๊ทœ ๋จผ ํŠธ

handle

detect_init api์— ์˜ ํ•˜ ์—ฌ ํ•  ๋‹น ๋œ detect handle resource.

inbuf

๋ฌธ ์ž ์…‹ ๊ณผ ์ • ํ™• ๋„ ๋ฅผ ์ธก ์ • ํ•  ์ž… ๋ ฅ ๋ฌธ ์ž ์—ด

inlen
๋ฌธ ์ž ์…‹ ๊ณผ ์ • ํ™• ๋„ ๋ฅผ ์ธก ์ • ํ•  ์ž… ๋ ฅ ๋ฌธ ์ž ์—ด ์˜ ๊ธธ ์ด

outbuf

inbuf ์˜ ๋ฌธ ์ž ์…‹ ๊ณผ ์ • ํ™• ๋„ ๋ฅผ ๊ตฌ ํ•˜ ์—ฌ ์ € ์žฅ ์„ ํ•œ ๋‹ค . outbuf ์˜ ๊ตฌ ์กฐ ๋Š” ๋‹ค ์Œ ๊ณผ ๊ฐ™ ๋‹ค .

typedef struct DetectObject {

char * encoding;

float confidence;

} DetectObj;

outbuf๋Š” detect_obj_init api๋ฅผ ์ด ์šฉ ํ•˜ ์—ฌ ์ดˆ ๊ธฐ ํ™” ๋ฅผ ํ•œ ํ›„ ์— detect api๋กœ ๋„˜ ๊ฒจ ์ค˜ ์•ผ ํ•œ ๋‹ค .

๋ฐ˜ ํ™˜ ๊ฐ’

๊ฒฝ ์šฐ ์— ๋”ฐ ๋ผ ์•„ ๋ž˜ ์˜ ์ƒ ํƒœ ๋ฅผ ๋ฐ˜ ํ™˜ ํ•œ ๋‹ค .
CHARDET_SUCCESS

์„ฑ ๊ณต

CHARDET_NO_RESULT

ํƒ ์ง€ ํ•˜ ์ง€ ๋ชป ํ–ˆ ์„ ๊ฒฝ ์šฐ

CHARDET_NULL_OBJECT

outbuf ์„ chardet_obj_init api๋ฅผ ์ด ์šฉ ํ•˜ ์—ฌ ๋ฉ” ๋ชจ ๋ฆฌ ํ•  ๋‹น ์„ ํ•˜ ์ง€ ์•Š ์•˜ ์„ ๊ฒฝ ์šฐ .

CHARDET_OUT_OF_MEMORY

๋‚ด ๋ถ€ API์— ์„œ out of memory ๊ฐ€ ๋ฐœ ์ƒ ํ–ˆ ์„ ๊ฒฝ ์šฐ

์˜ˆ ์ œ

#include <chardet.h>

int main (void) {

Detect * d;

DetectObj * obj;

int i, arrayNum;

char *str[] = {

"this is ascii",

"์ด ๊ฑด euc-kr ์ž… ๋‹ˆ ๋‹ค ."

};

arrayNum = sizeof (str) / sizeof (str[0]);

if ( (d = detect_init ()) == NULL ) {

fprintf (stderr, "chardet handle initialize failed\n");

return CHARDET_MEM_ALLOCATED_FAIL;

}

for ( i=0; i<arrayNum; i++ ) {

detect_reset (&d);

if ( (obj = detect_obj_init ()) == NULL ) {

fprintf (stderr, "Memory Allocation failed\n");

return CHARDET_MEM_ALLOCATED_FAIL;

}

//switch (detect_handledata (&d, str[i], &obj))

switch (detect_handledata_r (&d, str[i], strlen (str[i]), &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;

}

# obj-bom ์€ CHARDET_BOM_CHECK ์ƒ ์ˆ˜ ์ง€ ์› ์—ฌ ๋ถ€ ๋กœ ์ง€ ์› ์„ ํŒ ๋‹จ ํ•  ์ˆ˜ ์žˆ ์Šต ๋‹ˆ ๋‹ค .

printf ("encoding: %s, confidence: %f, exists bom: %d\n", obj->encoding, obj->confidence, obj->bom);

detect_obj_free (&obj);

}

detect_destroy (&d);

return 0;
}

์ € ์ž

๊น€ ์ • ๊ท 

๋ฒ„ ๊ทธ ๋ฆฌ ํฌ ํŠธ

https://github.com/Joungkyun/libchardet/issues

์ฐธ ๊ณ 

detect_obj_init(3), detect_obj_free(3), detect_init(3), detect_reset(3), detect_destroy(3)