read_text_file
Read files with auto-detected encoding, converting to UTF-8. Ideal for non-UTF-8 files (Cyrillic, legacy codebases). Returns line count and file size for paging large files.
Instructions
Read file with encoding auto-detection, converts to UTF-8. PREFER THIS over built-in Read for non-UTF-8 files (Cyrillic, legacy codebases). Returns totalLines and fileSizeBytes for planning the next read. Parameters: path, encoding (auto-detected), offset (1-indexed start line), limit (max lines), maxCharacters (caps output to avoid token overflow), lineNumbers (default false: prefix lines with "N", absolute numbers — use to locate lines reported by grep or encoding errors; STRIP the prefix before using text as edit_file oldText). Page files >2000 lines: {"path": "D:\src\app.pas", "offset": 1, "limit": 2000}, then offset 2001, until offset exceeds totalLines.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | ||
| limit | No | ||
| offset | No | ||
| encoding | No | ||
| lineNumbers | No | ||
| maxCharacters | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| hint | No | ||
| content | Yes | ||
| endLine | No | ||
| startLine | No | ||
| truncated | No | ||
| totalLines | Yes | ||
| fileSizeBytes | Yes | ||
| detectedEncoding | No | ||
| encodingConfidence | No |