Skip to content

A command-line tool for checking and converting text encoding.

License

Notifications You must be signed in to change notification settings

RyoNakagami/encoding-checker-cli

Repository files navigation

encoding-checker-cli

A command-line tool for detecting and converting text file encodings.

Features

  • Detects encoding of text files (e.g., UTF-8, Shift-JIS, EUC-JP)
  • CLI interface for quick checks
  • Python API for integration

Encoding Detection Strategy

see docs/ENCODING_DETECTION_STRATEGY.md

Usage

CLI

pycheck-encoding <filename>
$ pycheck-encoding --help

 Usage: pycheck-encoding [OPTIONS] [FILE_PATH]

 This script provides a simple command-line tool to detect the text
 encoding of a given file. It attempts to decode the file's binary
 contents using a list of common encodings including UTF-8, UTF-16,
 UTF-32, Shift_JIS, EUC-JP, ISO-8859 variants, CP932, and others.

 If the file can be successfully decoded with one of these encodings, the
 script reports the detected encoding. If none of the encodings work, it
 notifies the user that the encoding could not be determined.

╭─ Arguments ─────────────────────────────────────────────────────────────╮
│   file_path      [FILE_PATH]  Path to the file to check encoding.       │
╰─────────────────────────────────────────────────────────────────────────╯
╭─ Options ───────────────────────────────────────────────────────────────╮
│ --version  -v        Show version information and exit.                 │
│ --help               Show this message and exit.                        │
╰─────────────────────────────────────────────────────────────────────────╯

Python API

from encoding_checker_cli.encoding import detect_encoding

encoding = detect_encoding("sample.txt")
print(f"Detected encoding: {encoding}")

Installation

uv tool install git+https://github.com/RyoNakagami/encoding-checker-cli

Test

Run all tests with pytest:

pytest

See docs/TEST_STRATEGY.md for details.

License

MIT License

About

A command-line tool for checking and converting text encoding.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages