Detect encoding