When i did autodetection for PSPad, I took big texts (several sources for each encoding like books, internet pages, ...) I calculate occurence of all chars in text and created weight for each char
Now I take about forst 10 000 chars, calculate total weight from chars and decide what encoding it can be... -- <https://forum.pspad.com/read.php?2,71255,71256> PSPad freeware editor https://www.pspad.com
