autodetect encoding, if not set