# CSV文件使用UTF-8编码，但在期望Latin-1编码的工具（如Excel）中打开时显示为乱码

- **ID:** `data/csv-encoding-mismatch-latin1-vs-utf8`
- **领域:** data
- **类别:** encoding_error
- **验证级别:** ai_generated
- **修复率:** 90%

## 根因

CSV文件以UTF-8编码保存，但读取器或应用程序（如Excel）默认使用Latin-1（ISO 8859-1）编码，导致扩展字符被错误解释。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| pandas 1.5.0 | active | — | — |
| Python 3.10 | active | — | — |
| Excel 365 | active | — | — |
| LibreOffice 7.4 | active | — | — |

## 解决方案

1. ```
   使用Python重新保存CSV文件并显式指定UTF-8编码：df.to_csv('file.csv', encoding='utf-8-sig')，添加BOM以兼容Excel。
   ```
2. ```
   在文本编辑器中打开CSV文件，然后使用'另存为'功能选择UTF-8编码。在Excel中，使用数据>从文本/CSV导入，并选择'65001: Unicode (UTF-8)'作为文件来源。
   ```

## 无效尝试

- **Manually changing file extension to .txt and re-importing** — Does not address the underlying encoding issue; the data remains corrupted during import. (90% 失败率)
- **Using a hex editor to remove the UTF-8 BOM** — Removing BOM only affects byte order mark, not the actual encoding; data still garbled if reader assumes Latin-1. (70% 失败率)
