# UnicodeDecodeError: 'utf-8' 编解码器无法解码位置 0 的字节 0xff：无效起始字节

- **ID:** `python/pandas-csv-unicode-decode`
- **领域:** python
- **类别:** encoding_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

pd.read_csv 默认使用 UTF-8，但文件编码为 UTF-16（BOM 0xFF 0xFE）、Latin-1 或 CP1252。位置 0 的 0xff 是 UTF-16 LE BOM。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.x | active | — | — |

## 解决方案

1. **** (95% 成功率)
   ```
   pd.read_csv(path, encoding='utf-16')  # or 'latin-1' / 'cp1252'
   ```
2. **** (90% 成功率)
   ```
   Detect with `import chardet; enc = chardet.detect(open(path,'rb').read(10000))['encoding']`
   ```

## 无效尝试

- **** — Silently corrupts non-ASCII text (85% 失败率)
- **** — Same decode error on open() (90% 失败率)
