convert_encoding
Convert a file from one character encoding to another, with automatic source detection and BOM handling. Create a backup before irreversible conversions.
Instructions
Convert file from one encoding to another. Use after detect_encoding to identify the source. A source BOM is stripped before decoding, and a conflict between the BOM and an explicit 'from' is an error. No-op if the file already holds the target bytes. Parameters: path (required), from (source encoding, auto-detected if omitted), to (target encoding, required), backup (create .bak file before converting, default: false), bom (optional: "auto" default — BOM for UTF-16 targets and keeps a same-encoding source BOM; "always", "never", "preserve"). IMPORTANT: Use backup=true for irreversible conversions.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| to | Yes | ||
| bom | No | ||
| from | No | ||
| path | Yes | ||
| backup | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| hasBom | Yes | ||
| bomType | No | ||
| changed | Yes | ||
| message | Yes | ||
| backupPath | No | ||
| sourceEncoding | Yes | ||
| targetEncoding | Yes |