Skip to main content

Detect and normalize suspicious Unicode characters in text files.

Project description

fix-text

fix-text is a small Python CLI for detecting and cleaning suspicious Unicode characters in text files, including fullwidth spaces, non-breaking spaces, zero-width characters, BOM markers, and optional control characters.

What it fixes

  • Replaces fullwidth and non-standard spacing characters with a normal ASCII space
  • Removes zero-width characters and byte order marks
  • Optionally removes unsupported control characters with --include-controls
  • Validates cleaned .json files before rewriting them
  • Validates cleaned .yaml and .yml files before rewriting them
  • Scans individual files or entire directory trees

Install for development

This project is managed with uv.

uv sync

Install the test dependency group:

uv sync --group dev

Run the CLI without installing globally:

uv run fix-text --help

Run the test suite:

uv run --group dev pytest

Usage

Scan a file or directory:

uv run fix-text path/to/file.txt path/to/dir

Rewrite files in place:

uv run fix-text --apply path/to/file.txt

Include control-character cleanup:

uv run fix-text --apply --include-controls logs/

Treat additional suffixes as text:

uv run fix-text --ext .log --ext .cfg sample/

For .json files, fix-text validates the cleaned output with orjson before writing. For .yaml and .yml, it validates the cleaned output with PyYAML. If the cleaned content would still be invalid JSON or YAML, the file is left unchanged.

Example output

notes.txt
  3:14 U+3000 IDEOGRAPHIC SPACE '\u3000' -> replace with space
  8:2 U+200B ZERO WIDTH SPACE '\u200b' -> delete

Found 2 issue(s). Re-run with --apply to rewrite files.

PyPI release plan

  1. Replace the placeholder GitHub URLs in pyproject.toml.
  2. Create a PyPI account and API token.
  3. Build distributions with uv build.
  4. Publish with uv publish.
  5. Tag the release in git so the source and package versions stay aligned.

Recommended pre-release checks:

  • uv run fix-text --help
  • uv run fix-text README.md
  • uv run --group dev pytest
  • uv build --out-dir dist

Build into the repo-local dist/ directory:

./scripts/release.sh build

Publish the repo-local artifacts:

./scripts/release.sh publish

License

MIT

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

fix_text-0.1.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

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

fix_text-0.1.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file fix_text-0.1.0.tar.gz.

File metadata

  • Download URL: fix_text-0.1.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for fix_text-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5f4e30cdeb4f061e2b62609f6434c1134e7b57bfc41b9ec7387162dfb508c38c
MD5 dda524d0099453c8a2db57a0d1233e50
BLAKE2b-256 2660e2de94f267436385940e326ce9d25464bfd4378c7419315a440fa9692027

See more details on using hashes here.

File details

Details for the file fix_text-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: fix_text-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for fix_text-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c03a4656edc5b25f2bf4e30c8e5fd6e75c0d6d9b6892cdd71e7fccf84a98f1c5
MD5 6793a17494d22147950a14bd03fdcffd
BLAKE2b-256 137462cdd45a8984ca1b1944f8687b7c55c4cbd386e0596fc9c42463b132cc75

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