← Back to Pull requests

fix(csv): auto-add UTF-8 BOM when CSV output contains multibyte characters #171

Closed
unknown closed this pull request without merging on Jul 16, 2026 02:07 UTC
View on GitHub
unknown unknown commented on Jul 14, 2026 05:42 UTC
Author

Fixes garbled characters when opening exported CSV files in Excel.

Excel requires a UTF-8 BOM to correctly recognize UTF-8-encoded files. Without it, any CSV containing multibyte characters (CJK, etc.) may open with garbled text. This is confirmed by Microsoft's official documentation:

You can open a CSV file encoded with UTF-8 normally _if it was saved with BOM (Byte Order Mark)._

https://support.microsoft.com/en-us/excel/opening-csv-utf-8-files-correctly-in-excel

The existing get_csv_output_encoding() helper already had the correct logic, but it was simply never called. This PR wires it in.

Closes #170. Related to #50.

Changes

  • svc_md_to_csv.py — call get_csv_output_encoding() in write_text() instead of hardcoding utf-8; remove the unused encoding argument from the internal to_csv() call

  • Added a Chinese test resource and two tests: ASCII input produces no BOM, while multibyte input automatically produces a BOM
  • Testing

  • Unit tests pass (pytest test/skills/test_md_to_csv.py)

  • Verified on Dify 1.15.0 — exported CSV files with CJK content open correctly in Excel without any configuration changes
  • Diff: 146 lines (+109 / -37) across 1 files Reviewer: bowenliang123 Review duration: 2664m
    All Vouch review confidence checks passed
    Residual risk 0.14 = Change Risk (0.33) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.33 · 146 lines diff across 1 files
    0.33
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.299
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #171"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 32.8% (LOW) · Higher = larger blast radius
    32.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 14.2% · Safe to merge
    14.2%