File encoding detection improvement

if the file has multiple encodings, the ude detector sometimes has
problems choosing the encoding.
So we try again with only the first 4k.