Added option for auto encoding detection