this code would be more obvious if you pulled the endianness out of guessedEncoding straight away.