encoding-check-cli
v1.0.0
Published
Detect character encoding and line ending format of text files. Zero external dependencies.
Maintainers
Readme
encoding-check-cli (Node.js)
Detect character encoding and line ending format of text files. Zero external dependencies.
Installation
npm install -g encoding-check-cliUsage
encoding-check --files file1.txt file2.md
encoding-check --dir ./src --json
encoding-check file1.txt --dir ./docsOptions
| Option | Description | |--------|-------------| | --files <paths...> | One or more file paths to check | | --dir <dirs...> | Directories to recursively scan | | --json | Output results as JSON | | --help, -h | Show help message |
Detection Methods
- BOM detection: Checks for UTF-8, UTF-16 LE/BE, UTF-32 LE/BE BOM signatures
- UTF-8 validation: Full byte-by-byte validation per RFC 3629
- ASCII detection: All bytes in 0x00-0x7F range
- UTF-16 heuristic: Null byte pattern analysis
- Latin-1 fallback: Extended ASCII (0x80-0xFF) detection
- Line endings: CRLF (Windows), LF (Unix), CR (classic Mac), or mixed
Output
Without --json, output is formatted per file:
path/to/file.txt
Encoding: UTF-8 (confidence: high)
Line endings: CRLF (Windows)
Size: 1.2 KBWith --json, output is a JSON array of result objects.
License
MIT
