In the past PSPad detects ansi/utf-8 files only. For east Europe charsets it detects DOS too. Now it is able detect wide range of charsets. Your "guessing" means he calculates chars from each file, evaluates char weight in each charset and winner is selected. I agree, it isn't 100%, but it isn't random.
If you want to help and improve autodetection, I need files with wrong detection and info about correct code page. If file contains few accented chars only, the detection is hard. -- <https://forum.pspad.com/read.php?4,77125,77126> PSPad freeware editor https://www.pspad.com