Skip to main content

CLI tool to scan and convert source files to UTF-8 with BOM.

Project description

CUFT

CUFT is a CLI tool that scans source files, detects legacy encodings, and converts them to UTF-8 with BOM.

It can also report replacement characters () introduced by decoding issues.

Features

  • Scan one file or an entire directory tree.
  • Filter files by extension.
  • Detect source encoding with chardet.
  • Convert files to UTF-8 with BOM through iconv.
  • Optional backup copy of original files.
  • Detailed report for converted, skipped, and problematic files.

Requirements

  • Python 3.10+
  • uv (only for local development)
  • iconv available in your system PATH

Install iconv

  • macOS: usually preinstalled (iconv --version)
  • Linux: install from system package manager (for example libc-bin / glibc tools)
  • Windows: download and install GNU iconv for Windows (GnuWin32) and make sure iconv.exe is in PATH

Installation

Option A – Install from PyPI (recommended)

No need to clone the repository. Just run:

pip install cutf

or with uv:

uv tool install cutf

Then use it directly:

cutf --path ./src --all --extensions .py .txt

Option B – Clone and run locally

1) Clone the repository

git clone https://github.com/<your-org>/cutf.git
cd cutf

2) Create environment and install dependencies with uv

uv sync --all-groups

3) Run CUFT

uv run cutf --path ./src --all --extensions .py .txt

Usage

usage: cutf --path PATH [--checks] [--convert] [--copyOld]
            [--printMissingCharString] [--printAllSkippedFile]
            [--all] [--verbose] [--only-relevant]
            [--extensions EXT [EXT ...]]

Main options

  • --path: file or directory to process.
  • --checks: run missing-character checks.
  • --convert: convert non-UTF files to UTF-8 with BOM.
  • --all: enable both --checks and --convert.
  • --extensions: list of extensions to scan (required), for example .cpp .h .cs .ini.
  • --copyOld: copy original file before conversion into temp folder.
  • --printMissingCharString: print the line content for each missing-character finding.
  • --printAllSkippedFile: print every skipped file instead of only the count.
  • --only-relevant: hide less relevant missing-character entries.
  • --verbose: print extra execution logs.

Typical Commands

Run checks only:

uv run cutf --path ./project --checks --extensions .py .js .ts

Run conversion + checks:

uv run cutf --path ./project --all --extensions .cpp .h --copyOld

Process one file:

uv run cutf --path ./src/main.cpp --all --extensions .cpp

Development

Run tests:

uv run pytest

Run linter:

uv run ruff check .

Format code:

uv run ruff format .

FAQ

Why does CUFT require --extensions?

It prevents accidental processing of unrelated files and keeps scans predictable.

Why UTF-8 with BOM?

Some tools and Windows-oriented workflows require BOM for UTF-8 detection.

What happens if iconv is missing?

CUFT stops before processing and prints an error. Install iconv and retry.

Where are original files copied when --copyOld is enabled?

They are copied to <system-temp>/SrcChE.

Does CUFT modify UTF-8 files?

Only when conversion is requested and the file is detected as non-UTF. Otherwise files are skipped.

License

This project is distributed under the license in LICENSE.

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

cutf-0.0.8.tar.gz (58.5 kB view details)

Uploaded Source

Built Distribution

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

cutf-0.0.8-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file cutf-0.0.8.tar.gz.

File metadata

  • Download URL: cutf-0.0.8.tar.gz
  • Upload date:
  • Size: 58.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for cutf-0.0.8.tar.gz
Algorithm Hash digest
SHA256 f4f665fb29aa74e1e133b889f9827ba732cc5fb01699b1e49d2f1b02934da9a4
MD5 96e66af27f343cff110f619b49df7110
BLAKE2b-256 97a257fbe5b3fcceed29c47cbd4252de776a5fce058ee759c0c432ccfe62c1d6

See more details on using hashes here.

File details

Details for the file cutf-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: cutf-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for cutf-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 d5ca4e24f1cf9eeaff8e5ee35056fd14e1be627fb6fbe31b09a585b8b3b25bf5
MD5 5aa16f99f74d0c93e516f51d67e64d2d
BLAKE2b-256 b411e1e506df2ac1eb19d8acdda7fc82ae91b65772c90104e989d1ae6d89f912

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