#14 separate encoding detector from encoding implementation