Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions requirements/base.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ tqdm
psutil
python-oxmsg
html5lib
chardet
5 changes: 4 additions & 1 deletion unstructured/partition/common/common.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import chardet
import numbers
import subprocess
from io import BufferedReader, BytesIO, TextIOWrapper
Expand Down Expand Up @@ -296,7 +297,9 @@ def convert_office_doc(
wait_time = 0
sleep_time = 0.1
output = subprocess.run(command, capture_output=True)
message = output.stdout.decode().strip()
detected_encoding = chardet.detect(output.stdout)
encoding = detected_encoding['encoding'] or 'utf-8' # Default to utf-8 if detection fails
message = output.stdout.decode(encoding).strip()
# we can't rely on returncode unfortunately because on macOS it would return 0 even when the
# command failed to run; instead we have to rely on the stdout being empty as a sign of the
# process failed
Expand Down
Loading