# 由于Latin-1与UTF-8编码不匹配，CSV文件在Excel中打开时特殊字符静默损坏

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

## 根因

Excel默认假定CSV文件使用Latin-1（Windows-1252）编码，而现代数据工具以UTF-8导出，导致ü、ñ或€等字符显示为乱码。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Microsoft Excel 2021 | active | — | — |
| Microsoft Excel 365 | active | — | — |
| LibreOffice Calc 7.5 | active | — | — |

## 解决方案

1. ```
   Add UTF-8 BOM to the CSV file: echo -e '\xEF\xBB\xBF' > output.csv; cat original.csv >> output.csv; then open in Excel
   ```
2. ```
   Use Python to convert CSV to Latin-1 encoding: with open('input.csv', 'r', encoding='utf-8') as f, open('output.csv', 'w', encoding='latin-1') as out: out.write(f.read())
   ```

## 无效尝试

- **Adding UTF-8 BOM to the file without verifying Excel version compatibility** — UTF-8 BOM may cause Excel to detect encoding correctly but adds invisible characters to first column header. (60% 失败率)
- **Converting file to UTF-16 which Excel supports but causes other issues** — This changes the data format and may break downstream systems expecting UTF-8. (75% 失败率)
