Fix encoding if not utf-8
Extract methods