A Python package for encoding files with various character encodings.
- CLI tool for encoding files with different character encodings
- Support for multiple encodings: UTF-8, UTF-16, UTF-32, ASCII, Latin-1, CP1252, and more
- Automatic encoding detection for input files
- Configurable output file paths
- Comprehensive test suite with pytest
Install the package in development mode:
pip install -e .For development with test dependencies:
pip install -e ".[dev]"The package provides an encode command that can be used to encode files:
# Basic usage with default UTF-8 encoding
encode input.txt
# Specify a custom encoding
encode input.txt --encoding ascii
# Specify custom output file
encode input.txt --output encoded_file.txt --encoding utf-16
# Verbose output
encode input.txt --encoding latin-1 --verboseYou can also use the FileEncoder class directly in your Python code:
from file_encoder import FileEncoder
encoder = FileEncoder()
# Encode a file with default UTF-8 encoding
output_path = encoder.encode_file('input.txt')
# Encode with custom encoding and output path
output_path = encoder.encode_file(
input_path='input.txt',
output_path='encoded.txt',
encoding='utf-16'
)
# Detect file encoding
encoding = encoder.get_file_encoding('somefile.txt')- utf-8 (default)
- utf-16
- utf-32
- ascii
- latin-1
- cp1252
- iso-8859-1
- windows-1252
- big5
- gb2312
- shift_jis
Run the test suite with pytest:
pytestRun tests with coverage:
pytest --cov=file_encoderThis project uses:
pyproject.tomlfor project configurationclickfor the CLI interfacepytestfor testing- Modern Python packaging standards
https://docs.github.com/en/actions/get-started/quickstart https://docs.github.com/en/billing/concepts/product-billing/github-actions https://docs.aws.amazon.com/codebuild/latest/userguide/action-runner.html# Test