write_file
Write files by converting UTF-8 content to a target encoding, with BOM handling. Use after reading a file to preserve its original encoding.
Instructions
Write file with encoding conversion from UTF-8. PREFER THIS over built-in Write for non-UTF-8 files — converts UTF-8 content to target encoding, preserving legacy compatibility. Parameters: path (required), content (required), encoding (optional: defaults to an existing file's detected encoding, else utf-8), bom (optional: "auto" default — BOM for UTF-16 targets and keeps a BOM the file already had; "always", "never", "preserve"). Use after read_text_file to preserve original encoding.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bom | No | ||
| path | Yes | ||
| content | Yes | ||
| encoding | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| hasBom | Yes | ||
| bomType | No | ||
| message | Yes |