[Bug] Attachment names extracted via /tools/extract-attachments/ are garbled (likely UTF-8 decoded as Latin-1/Windows-1252)
Minimal Reproducible Example_with_attachments.pdf
Description
When using the /tools/extract-attachments/ tool to extract embedded files from a PDF, the extracted filenames appear garbled (e.g., showing as ç¨ä½éä»¶). However, when opening the same PDF with other PDF readers or tools, the original filenames display correctly in proper Chinese (e.g., 程佑附件).
This strongly looks like a character encoding issue where UTF-8 encoded bytes (or PDF Doc Encoding / UTF-16 strings) are being incorrectly decoded or interpreted as Latin-1 / Windows-1252.
Steps to Reproduce
Go to /tools/extract-attachments/.
Upload a PDF file that contains attachments with non-ASCII (e.g., Chinese) filenames.
Extract the attachments.
Observe the resulting filenames in the download list or the extracted files.
Expected Behavior
The extracted attachment filenames should preserve their original characters correctly (e.g., 程佑附件), matching what is embedded in the PDF metadata.
Actual Behavior
Filenames are corrupted into mojibake strings (e.g., ç¨ä½éä»¶).
Source: PDFCraftTool/pdfcraft