fixed a typo in encoding detection routine.