Skip to main content

A CLI tool to convert files (.cpp, .h, etc.) to UTF-8 encoding.

Project description

⚠️ Note: This README and project structure were generated with the help of a large language model (LLM). Please review before publishing or deploying.

PyPI version

utf8convert

A command-line utility to recursively convert source files to UTF-8 encoding.

Supports:

  • .cpp, .h, .hpp files by default
  • Any custom extensions via --extensions
  • Logging with timestamped filenames
  • Dry-run mode
  • Skip ASCII files (optional)
  • JSON summary output (optional)
  • Separate counts for intentionally skipped files and error cases
  • Default and user-defined subdirectory exclusions

📦 GitHub

Project repository: https://github.com/yhbyhb/utf8convert


🚀 Installation

You can install the package locally after downloading or cloning the repo:

pip install .

This will install the executable command: utf8convert


💻 Usage

utf8convert [DIRECTORY] [OPTIONS]

Options:

  • --dry-run
    Preview files to convert without modifying anything.

  • --extensions [.ext1 .ext2 ...]
    List of file extensions to process (default: .cpp .h .hpp).

  • --exclude-dirs [dir1 dir2 ...]
    Relative paths of subdirectories to skip.
    Defaults: .git, .vs, vcpkg_installed, and any dot-prefixed folders.

  • --skip-ascii
    Skip files detected with ASCII encoding (they're usually already compatible with UTF-8).

  • --json-output PATH
    Write a summary report as JSON to the specified path (not printed in logs).


📊 Summary Breakdown

The summary will show:

  • Total scanned
  • Already UTF-8
  • Converted or would-convert
  • Skipped (intentionally ignored, like ASCII)
  • Errors (files that failed to decode/convert)

📌 Examples

🔍 Dry-run all C++ headers and sources

utf8convert ./src --dry-run

🛠 Convert files with .c and .cc extensions too

utf8convert ./src --extensions .cpp .h .hpp .c .cc

🧾 Generate a JSON report

utf8convert ./mycode --json-output utf8_summary.json

🚫 Skip specific folders

utf8convert ./codebase --exclude-dirs build third_party .cache

⚙️ Skip ASCII-encoded files

utf8convert ./legacy --skip-ascii

🧪 Test Locally

hatch run python -m utf8convert.cli ./your/code --dry-run

⚠️ Note: This README and project structure were generated with the help of a large language model (LLM). Please review before publishing or deploying.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

utf8convert-0.2.0.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

utf8convert-0.2.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file utf8convert-0.2.0.tar.gz.

File metadata

  • Download URL: utf8convert-0.2.0.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for utf8convert-0.2.0.tar.gz
Algorithm Hash digest
SHA256 cb75818de40241922d8e4ec830367fdf1acca4341653af00470c6b633a2aff8a
MD5 b4a5a0a7574aada9531c3872639ac81c
BLAKE2b-256 0eac53a57e90db14e719495da7058730a55f28e5e2c91354f8c89edd44547f55

See more details on using hashes here.

File details

Details for the file utf8convert-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: utf8convert-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for utf8convert-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c16b94bb3e9b96488646b34e15d2f60c12d68d2d8bfa5bc6c5ac37004ee5bc7b
MD5 7519aa178168d4f438528087f0960238
BLAKE2b-256 37742809016235d3095e5a5b7bcc150296608e2a9cd029804db7bb1507f76939

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page