fix: add UTF-8 BOM to CSV for Excel compatibility#575
Open
MoshiLL wants to merge 3 commits intofunstory-ai:mainfrom
Open
fix: add UTF-8 BOM to CSV for Excel compatibility#575MoshiLL wants to merge 3 commits intofunstory-ai:mainfrom
MoshiLL wants to merge 3 commits intofunstory-ai:mainfrom
Conversation
## Problem CSV files with Chinese characters show garbled text when opened in Windows Excel ## Solution Add UTF-8 BOM (EF BB BF) to CSV files so Excel recognizes UTF-8 encoding ## Files Modified - babeldoc/format/pdf/document_il/midend/automatic_term_extractor.py - babeldoc/format/pdf/result_merger.py ## Testing - [x] CSV opens correctly in Windows Excel with Chinese characters
## Problem CSV files with Chinese characters show garbled text when opened in Windows Excel ## Solution Add UTF-8 BOM (EF BB BF) to CSV files so Excel recognizes UTF-8 encoding ## Files Modified - babeldoc/format/pdf/document_il/midend/automatic_term_extractor.py - babeldoc/format/pdf/result_merger.py ## Testing - [x] CSV opens correctly in Windows Excel with Chinese characters
## Problem CSV files with Chinese characters show garbled text when opened in Windows Excel ## Solution Add UTF-8 BOM (EF BB BF) to CSV files so Excel recognizes UTF-8 encoding ## Files Modified - babeldoc/format/pdf/document_il/midend/automatic_term_extractor.py - babeldoc/format/pdf/result_merger.py ## Testing - [x] CSV opens correctly in Windows Excel with Chinese characters
There was a problem hiding this comment.
1 issue found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="babeldoc/format/pdf/document_il/midend/automatic_term_extractor.py">
<violation number="1" location="babeldoc/format/pdf/document_il/midend/automatic_term_extractor.py:397">
P2: JSON debug artifacts are now written with UTF-8 BOM (`utf-8-sig`), reducing interoperability and potentially breaking downstream parsers expecting standard BOM-less UTF-8 JSON.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| ) | ||
| logger.debug(f"save translate tracking to {path}") | ||
| with Path(path).open("w", encoding="utf-8") as f: | ||
| with Path(path).open("w", encoding="utf-8-sig") as f: |
There was a problem hiding this comment.
P2: JSON debug artifacts are now written with UTF-8 BOM (utf-8-sig), reducing interoperability and potentially breaking downstream parsers expecting standard BOM-less UTF-8 JSON.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At babeldoc/format/pdf/document_il/midend/automatic_term_extractor.py, line 397:
<comment>JSON debug artifacts are now written with UTF-8 BOM (`utf-8-sig`), reducing interoperability and potentially breaking downstream parsers expecting standard BOM-less UTF-8 JSON.</comment>
<file context>
@@ -394,14 +394,14 @@ def procress(self, doc_il: ILDocument):
)
logger.debug(f"save translate tracking to {path}")
- with Path(path).open("w", encoding="utf-8") as f:
+ with Path(path).open("w", encoding="utf-8-sig") as f:
f.write(tracker.to_json())
</file context>
Suggested change
| with Path(path).open("w", encoding="utf-8-sig") as f: | |
| with Path(path).open("w", encoding="utf-8") as f: |
corriuneasley1-pixel
approved these changes
Mar 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Title
fix: add UTF-8 BOM to CSV for Excel compatibility
Related Issue(s)
Motivation and Context
CSV files with Chinese characters display garbled text when opened in Windows Excel
because Excel doesn't recognize UTF-8 encoding by default. Adding UTF-8 BOM (EF BB BF)
solves this problem.
Summary of Changes
PR Type
Breaking Changes
Testing Instructions
Contributor Checklist
Summary by cubic
Add a UTF-8 BOM to exported glossary CSVs so Windows Excel detects UTF-8 and displays Chinese correctly. Also save
term_extractor_tracking.jsonandterm_extractor_freq.jsonwith UTF-8 BOM, and export glossary CSVs without the index.Written for commit 3bcb1be. Summary will update on new commits.