Extract encoding detection into helper function
Extract encoding detection into helper function

pypa/pip,sbidoul/pip,pypa/pip,xavfernandez/pip,rouge8/pip,pfmoore/pip,xavfernandez/pip,pfmoore/pip,sbidoul/pip,rouge8/pip,rouge8/pip,pradyunsg/pip,xavfernandez/pip,pradyunsg/pip