Fix: encode detect error. (#6006)

### What problem does this PR solve?

#5967

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
Kevin Hu 2025-03-13 10:47:58 +08:00 committed by GitHub
parent 3571270191
commit e05cdc2f9c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -53,7 +53,8 @@ all_codecs = [
def find_codec(blob):
detected = chardet.detect(blob[:1024])
if detected['confidence'] > 0.5:
return detected['encoding']
if detected['encoding'] == "ascii":
return "utf-8"
for c in all_codecs:
try: