get_best_eci: check UTF-8 before returning 26; move is_valid_utf8 to common

This commit is contained in:
gitlost 2021-03-21 17:35:52 +00:00
parent 7f74414666
commit 2d962c6321
7 changed files with 104 additions and 64 deletions

View file

@ -271,5 +271,9 @@ INTERNAL int get_best_eci(const unsigned char source[], int length) {
eci++;
} while (eci < 25);
if (!is_valid_utf8(source, length)) {
return 0;
}
return 26; // If all of these fail, use Unicode!
}