{
  "id": "data/csv-encoding-mismatch-latin1-vs-utf8",
  "signature": "CSV file with UTF-8 encoded data displays as garbled text when opened in Excel or other tools expecting Latin-1",
  "signature_zh": "CSV文件使用UTF-8编码，但在期望Latin-1编码的工具（如Excel）中打开时显示为乱码",
  "regex": "garbled|mojibake|encoding|UTF-8|Latin-1|ISO 8859-1",
  "domain": "data",
  "category": "encoding_error",
  "subcategory": null,
  "root_cause": "CSV files are saved with UTF-8 encoding but the reader or application (e.g., Excel) defaults to Latin-1 (ISO 8859-1), causing extended characters to be misinterpreted.",
  "root_cause_type": "generic",
  "root_cause_zh": "CSV文件以UTF-8编码保存，但读取器或应用程序（如Excel）默认使用Latin-1（ISO 8859-1）编码，导致扩展字符被错误解释。",
  "versions": [
    {
      "version": "pandas 1.5.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Python 3.10",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Excel 365",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "LibreOffice 7.4",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Manually changing file extension to .txt and re-importing",
      "why_fails": "Does not address the underlying encoding issue; the data remains corrupted during import.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using a hex editor to remove the UTF-8 BOM",
      "why_fails": "Removing BOM only affects byte order mark, not the actual encoding; data still garbled if reader assumes Latin-1.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Re-save the CSV with explicit UTF-8 encoding using Python: df.to_csv('file.csv', encoding='utf-8-sig') to add BOM for Excel compatibility.",
      "success_rate": 0.85,
      "how": "Re-save the CSV with explicit UTF-8 encoding using Python: df.to_csv('file.csv', encoding='utf-8-sig') to add BOM for Excel compatibility.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Open the CSV in a text editor, then use 'Save As' with UTF-8 encoding. In Excel, use Data > From Text/CSV and select '65001: Unicode (UTF-8)' as the file origin.",
      "success_rate": 0.9,
      "how": "Open the CSV in a text editor, then use 'Save As' with UTF-8 encoding. In Excel, use Data > From Text/CSV and select '65001: Unicode (UTF-8)' as the file origin.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "使用Python重新保存CSV文件并显式指定UTF-8编码：df.to_csv('file.csv', encoding='utf-8-sig')，添加BOM以兼容Excel。",
    "在文本编辑器中打开CSV文件，然后使用'另存为'功能选择UTF-8编码。在Excel中，使用数据>从文本/CSV导入，并选择'65001: Unicode (UTF-8)'作为文件来源。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2023-03-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}