Character encoding autodetection