Simplify the encoding parsing routine

Use None as a sentry value and impose the default if it ends up still None after we look at the lines.

This lets us get rid of the enumerate() and magic number 0.