support and tests for reading text files with encoding detection