Handle CSV preview issue

This improves the handling of badly encoded CSV files so it fails more
gracefully when encountering dodgy characters.
Mark non-public methods as private