die with helpful error if encoding cannot be determined

we cannot use the logger as we need to have the encoding first.