detect_encoding
Detect a file's encoding with a confidence score and BOM detection to resolve garbled text. Use before reading to apply the correct encoding.
Instructions
Auto-detect file encoding with confidence score (0-100) and BOM detection. ALWAYS use this first when encountering garbled text or � characters. Use before read_text_file to determine the correct encoding. Parameters: path (required), mode (sample=fast default, chunked=thorough, full=entire file). When the answer is in doubt the result also ranks candidates, all of them usable; retry the read with one and ask the user if two are plausible. A file the detector cannot place is refused rather than guessed at, with the same ranking in the error.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mode | No | ||
| path | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| has_bom | Yes | ||
| encoding | Yes | ||
| candidates | No | ||
| confidence | Yes |