file(1)がLatin-1(2 )は、別のエンコーディングでフラグメントを含むかもしれませんか?ファイルのサイズはどれくらいですか? 「定期的な検出ライブラリ」とは何ですか?たとえばWindowsのエンコードなどの可能性を考えましたか? cp1252?
いくつかの広いブラシ診断:
# preliminaries
text = open('the_file.txt', 'rb').read()
print len(text), "bytes in file"
# How many non-ASCII bytes?
print sum(1 for c in text if c > '\x7f'), "non-ASCII bytes"
# Will it decode as UTF-8 OK?
try:
junk = text.decode('utf8')
print "utf8 decode OK"
except UnicodeDecodeError, e:
print e
# Runs of more than one non-ASCII byte are somewhat rare in single-byte encodings
# of languages written in a Latin script ...
import re
runs = re.findall(r'[\x80-\xff]+', text)
nruns = len(runs)
print nruns, "runs of non-ASCII bytes"
if nruns:
avg_rlen = sum(len(run) for run in runs)/float(nruns)
print "average run length: %.2f bytes" % avg_rlen
# then if indicated you could write some code to display runs in context ...
私はあなたの痛みを感じるが、あなたは[enca](http://linux.die.net/man/1/enca)のようなものを試してみましたか? – Gleno
Encaは完璧に見えますが、奇妙なことに、英語をサポートしていないようです。東ヨーロッパ言語のほんの一束。英語で広範囲な文書があるので、本当に奇妙です。 – Alex
異常の例を教えてください。 UTF8などの8ビット文字セットをお探しですか?コードポイント0x80-0x9Fはラテン語では定義されていませんが、それ以外の場合はすべてのシーケンスが有効です。あなたがKOI-8rのようなものを探しているのであれば、ラテン文字、レター周波数、およびnグラムの文字シーケンスは良いヒューリスティックですが、個々のキャラクターごとに確実に知る方法はありません。 – tripleee