diff --git a/src/tools/uchardet.cpp b/src/tools/uchardet.cpp index 3952e61..5e49e72 100644 --- a/src/tools/uchardet.cpp +++ b/src/tools/uchardet.cpp @@ -51,9 +51,11 @@ void detect(FILE * fp) { uchardet_t handle = uchardet_new(); - while (!feof(fp)) + while (1) { size_t len = fread(buffer, 1, BUFFER_SIZE, fp); + if (len == 0) + break; int retval = uchardet_handle_data(handle, buffer, len); if (retval != 0) {