🐛 Lille bugfix

This commit is contained in:
Nikolaj
2021-09-09 08:29:52 +02:00
parent 15f9249a2c
commit 7d9457eb24
2 changed files with 9 additions and 6 deletions

BIN
A0/file

Binary file not shown.

View File

@ -9,22 +9,25 @@ enum FileType{ASCII, ISO, UTF, data};
bool is_utf8(FILE* f) { bool is_utf8(FILE* f) {
rewind(f); rewind(f);
char byte; char byte;
bool utf8_byte; int char_length = -1;
int char_length;
for (;;) { for (;;) {
if (fread(&byte, 1, 1, f) == 0) { if (fread(&byte, 1, 1, f) == 0) {
break; break;
} }
utf8_byte = true; for (int j = 0 ; j <= 8 ; j++) {
for (int j = 0 ; 1 ; j++) {
if (byte >> 7 == 0) { if (byte >> 7 == 0) {
char_length = max(j, 1); char_length = j;
break; break;
} }
byte = byte << 1; byte = byte << 1;
} }
if (char_length == -1) {
return false;
}
for (int i = 1 ; i < char_length ; i++) { for (int i = 1 ; i < char_length ; i++) {
printf("esnathusrcaho"); if (fread(&byte, 1, 1, f) == 0 || byte >> 6 != 2) {
return false;
}
} }
} }
return true; return true;