detect encoding