detect_reset(3)

πŸ“¦
version 1.0.6 Β· 4 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ detect_reset β€” the manual page bestie ✨

okay so this is a page from the detect_reset(3) manual β€” yes, that's the library functions manual, section 3, we're doing C library calls today and honestly? iconic. sit down, grab a strawberry, we're resetting a Detect structure together πŸ’–


πŸŽ€ NAME πŸŽ€

detect_reset β€” reset that Detect structure, bestie πŸ’…


🌸 SNOPSIS 🌸

(not me spelling it exactly like the source does β€” we do not fix it, that's the whole vibe)
#include <chardet.h>
void chardet_reset (Detect **handle);

πŸ’œ DESCRIPTION πŸ’œ

It resets the Detect structure. That's it. That's the whole job. It's giving "quiet luxury" β€” no drama, no fuss, just a lil reset so you can reuse your handle for the next round. πŸ¦‹


⭐ RETURN VALUE ⭐

void. She returns nothing. Zero. Nada. Empty-handed but absolutely slaying. πŸ’€


πŸ”₯ EXAMPLE πŸ”₯

here's the whole thing, copy it, love it, run it:

#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, "ΒΎΓˆΒ³Γ§Γ‡ΓΒΌΒΌΒΏΓ€", &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;
}

see how detect_reset (&d) shows up at the top of every loop iteration? that's the moment. main character energy. she wipes the slate so the next detect_handledata call doesn't get confused by the last one's baggage. no cap. 🫢


πŸ‘‘ AUTHORS πŸ‘‘

JoungKyun.Kim <http://oops.org> β€” the icon, the legend, the moment 🌈


🧚 BUG REPORTS 🧚

Use QnA board on https://github.com/Joungkyun/libchardet/issues β€” take it to the issues, bestie, that's where the discourse lives πŸ’Œ


πŸ¦‹ SEE ALSO πŸ¦‹

the whole friend group fr fr, go read them too πŸ’–


and that's the page!! this one came out of the libchardet manuals, dated 2019-08-01, and yeah the footer says detect_reset(3) but you already knew that. periodt. πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from