# 错误：无法映射的字符 (0x80) 用于编码 UTF-8

- **ID:** `java/unmappable-character-encoding`
- **领域:** java
- **类别:** encoding_error
- **验证级别:** ai_generated
- **修复率:** 90%

## 根因

Java 源文件包含编译器指定的 UTF-8 编码中无效的字节序列，通常是由于字符串字面量或注释中存在非 UTF-8 字符（例如来自 Windows-1252 或 ISO-8859-1）。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Java 8 | active | — | — |
| Java 11 | active | — | — |
| Java 17 | active | — | — |
| Java 21 | active | — | — |

## 解决方案

1. ```
   Specify the correct source encoding to javac using the -encoding flag. If the file is actually in Windows-1252, use -encoding Cp1252.
   ```
2. ```
   Convert the source file to UTF-8 using a tool like iconv or a text editor that supports encoding conversion.
   ```
3. ```
   Use native2ascii to escape the unmappable character as a Unicode escape sequence.
   ```

## 无效尝试

- **** — Changing the system locale does not affect the javac encoding; the compiler encoding must be explicitly set. (95% 失败率)
- **** — Adding -Dfile.encoding=UTF-8 to JVM arguments does not affect javac compilation encoding. (90% 失败率)
- **** — Removing the character without understanding its origin may break the intended functionality (e.g., a special symbol in a string). (60% 失败率)
