Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle non-UTF8 text file encodings for European language support #298

Closed
lemig opened this issue Jan 30, 2025 · 0 comments · Fixed by #299
Closed

Handle non-UTF8 text file encodings for European language support #298

lemig opened this issue Jan 30, 2025 · 0 comments · Fixed by #299

Comments

@lemig
Copy link
Contributor

lemig commented Jan 30, 2025

Description

When processing text files in the document conversion pipeline, we're currently assuming UTF-8 encoding which fails for files using different character encodings common in European languages.

Current Behavior

  • The system assumes UTF-8 encoding for all text files
  • Files with different encodings (e.g., Windows-1252, ISO-8859-1) fail with UnicodeDecodeError
  • Example error:
    UnicodeDecodeError: 'utf-8' codec can't decode byte 0x93 in position 1160: invalid start byte
    

Use Case Context

  • Working with digital forensics in a European agency
  • Need to handle documents in various European languages
  • Files may use different character encodings depending on their origin and creation time

Proposed Solution

Implement a more robust text file reading mechanism that:

  1. Attempts to read files with multiple common European encodings:
    • UTF-8
    • Windows-1252 (cp1252)
    • ISO-8859-1
    • Latin-1
  2. Provides a fallback mechanism for unrecognized encodings
  3. Potentially uses character encoding detection libraries (like chardet)

Technical Details

Current problematic code:

server/app/routes/convert.py (177-178)

# For txt files, just read the content
with open(file_path, 'r', encoding='utf-8') as f:
    content = f.read()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant