fix detect encoding in reader