Skip to main content

Encoder for unicode to RTF 1.5 command sequences

Project description

Unicode to RTF command code conversion

PyPI version License Python versions supported Built with uv Checked with Ruff Checked with Pyright Python checks Coverage

This module implements an encoder for unicode to RTF 1.5 command sequences; it can be used to generate valid RTF output with international characters.

Importing this module adds a new rtfunicode codec, allowing you to encode unicode strings to valid RTF bytecode sequences:

>>> import rtfunicode
>>> 'RTF and unicode mix just fine! \u263A'.encode('rtfunicode')
'RTF and unicode mix just fine! \\u9786?'

The RTF command code for a unicode character is \uN?, where N is a signed 16-bit integer and the ? is a placeholder character for older RTF readers. This module sets the latter to the '?' literal for simplicity's sake.

Requirements

  • Python 3.10 or newer.

Development

The project code is hosted on GitHub, feel free to report issues, fork the code and issue pull requests.

This project uses uv to handle Python dependencies and environments; use uv sync to get an up-to-date virtualenv with all dependencies. This includes development dependencies such as Ruff (used for linting and formatting) and Pyright (used to validate type annotations).

Linting and formatting

While PRs and commits on GitHub are checked for linting and formatting issues, it's easier to check for issues locally first. After running uv sync, run uv run pre-commit install to install pre-commit hooks that will run these tools and format your changes automatically on commits. These hooks also run uv sync whenever your working tree changes.

Testing

This project uses pytest to run its tests: uv run pytest.

License

BSD 2-Clause (simplified), see: LICENSE.txt

Author

Martijn Pieters mj@zopatista.com

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

rtfunicode-2.3.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

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

rtfunicode-2.3-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file rtfunicode-2.3.tar.gz.

File metadata

  • Download URL: rtfunicode-2.3.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rtfunicode-2.3.tar.gz
Algorithm Hash digest
SHA256 800d1ef6dcc01505a5912958e7267332ccb1a58e0c6faf213af5f9cd85fa321a
MD5 639f14b36e9b0b093065791ab14747c7
BLAKE2b-256 92265e41e1d4f579137b35729b2f764f405989181fd53bb14645ac00fb23630b

See more details on using hashes here.

Provenance

The following attestation bundles were made for rtfunicode-2.3.tar.gz:

Publisher: ci-cd.yml on mjpieters/rtfunicode

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rtfunicode-2.3-py3-none-any.whl.

File metadata

  • Download URL: rtfunicode-2.3-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rtfunicode-2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 60c2948fed7bd46a07cd9227c5f4cb2580d819b3bc56272734b9fcbc1a6cb594
MD5 2f0bb1623568b64a0a0f23fdfac6ba85
BLAKE2b-256 086c371cae9cee339dc234f9f1ad082e40cb083f744e790bd9408357dfd9ecdd

See more details on using hashes here.

Provenance

The following attestation bundles were made for rtfunicode-2.3-py3-none-any.whl:

Publisher: ci-cd.yml on mjpieters/rtfunicode

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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